1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Merge branch '10.3' into 10.4

This commit is contained in:
Oleksandr Byelkin
2019-05-19 20:55:37 +02:00
3893 changed files with 11766 additions and 6460 deletions

View File

@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
/* This file is originally from the mysql distribution. Coded by monty */
@ -941,6 +941,27 @@ String *copy_if_not_alloced(String *to,String *from,uint32 from_length)
(void) from->realloc(from_length);
return from;
}
if (from->uses_buffer_owned_by(to))
{
DBUG_ASSERT(!from->is_alloced());
DBUG_ASSERT(to->is_alloced());
/*
"from" is a constant string pointing to a fragment of alloced string "to":
to= xxxFFFyyy
- FFF is the part of "to" pointed by "from"
- xxx is the part of "to" before "from"
- yyy is the part of "to" after "from"
*/
uint32 xxx_length= (uint32) (from->ptr() - to->ptr());
uint32 yyy_length= (uint32) (to->end() - from->end());
DBUG_ASSERT(to->length() >= yyy_length);
to->length(to->length() - yyy_length); // Remove the "yyy" part
DBUG_ASSERT(to->length() >= xxx_length);
to->replace(0, xxx_length, "", 0); // Remove the "xxx" part
to->realloc(from_length);
to->set_charset(from->charset());
return to;
}
if (to->alloc(from_length))
return from; // Actually an error
if ((to->str_length=MY_MIN(from->str_length,from_length)))