diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-19 12:25:00 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-19 12:25:00 +0300 |
commit | f3fcf5f45c9c09242bfb8762a88c26238458e4c2 (patch) | |
tree | 914f1a5d9bd38b9f9d09d0c39306c80c00e21842 /sql/field.h | |
parent | 475f69b98587c2a0842e3fcbfe515e4362ded973 (diff) | |
parent | 17980e35fafdf0b05c89c11ecafbea96e1cfc5e5 (diff) | |
download | mariadb-git-f3fcf5f45c9c09242bfb8762a88c26238458e4c2.tar.gz |
Merge 10.5 to 10.6
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 4b64742b7b3..94a45d23802 100644 --- a/sql/field.h +++ b/sql/field.h @@ -4561,7 +4561,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())) @@ -4573,6 +4579,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() { |