diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-18 18:22:35 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-18 18:22:35 +0300 |
commit | 4a2595727465648f2d4e794d1b2f182345f0bee8 (patch) | |
tree | 8d4734e6c5b2795455416191ca50d5a0fbd23cd9 /sql/field.h | |
parent | da171182b7d79d21177d113d2bbaecbca21d8bbc (diff) | |
parent | f84e28c119b495da77e197f7cd18af4048fc3126 (diff) | |
download | mariadb-git-4a2595727465648f2d4e794d1b2f182345f0bee8.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/field.h')
-rw-r--r-- | sql/field.h | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/sql/field.h b/sql/field.h index 9fe4db3b521..6ada7f94507 100644 --- a/sql/field.h +++ b/sql/field.h @@ -4554,7 +4554,13 @@ public: uchar *new_ptr, uint32 length, uchar *new_null_ptr, uint new_null_bit) override; void sql_type(String &str) const override; - inline bool copy() + /** + Copy blob buffer into internal storage "value" and update record pointer. + + @retval true Memory allocation error + @retval false Success + */ + bool copy() { uchar *tmp= get_ptr(); if (value.copy((char*) tmp, get_length(), charset())) @@ -4566,6 +4572,33 @@ public: memcpy(ptr+packlength, &tmp, sizeof(char*)); return 0; } + void swap(String &inout, bool set_read_value) + { + if (set_read_value) + read_value.swap(inout); + else + value.swap(inout); + } + /** + Return pointer to blob cache or NULL if not cached. + */ + String * cached(bool *set_read_value) + { + char *tmp= (char *) get_ptr(); + if (!value.is_empty() && tmp == value.ptr()) + { + *set_read_value= false; + return &value; + } + + if (!read_value.is_empty() && tmp == read_value.ptr()) + { + *set_read_value= true; + return &read_value; + } + + return NULL; + } /* store value for the duration of the current read record */ inline void swap_value_and_read_value() { |