1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY

This commit is contained in:
Alexander Barkov
2020-03-10 16:05:42 +04:00
parent 00749980ac
commit e40858a7bd
35 changed files with 895 additions and 10 deletions

View File

@ -1032,6 +1032,39 @@ void Protocol_text::remove_last_row()
}
static MARIADB_CONST_STRING ma_const_string_copy_root(MEM_ROOT *memroot,
const char *str,
size_t length)
{
MARIADB_CONST_STRING res;
if (!str || !(res.str= strmake_root(memroot, str, length)))
return null_clex_str;
res.length= length;
return res;
}
class Client_field_extension: public Sql_alloc,
public MARIADB_FIELD_EXTENSION
{
public:
Client_field_extension()
{
memset(this, 0, sizeof(*this));
}
void copy_extended_metadata(MEM_ROOT *memroot,
const Send_field_extended_metadata &src)
{
for (uint i= 0; i <= MARIADB_FIELD_ATTR_LAST; i++)
{
LEX_CSTRING attr= src.attr(i);
metadata[i]= ma_const_string_copy_root(memroot, attr.str, attr.length);
}
}
};
bool Protocol_text::store_field_metadata(const THD * thd,
const Send_field &server_field,
CHARSET_INFO *charset_for_protocol,
@ -1080,6 +1113,17 @@ bool Protocol_text::store_field_metadata(const THD * thd,
client_field->catalog= dup_str_aux(field_alloc, "def", 3, cs, thd_cs);
client_field->catalog_length= 3;
if (server_field.has_extended_metadata())
{
Client_field_extension *ext= new (field_alloc) Client_field_extension();
if ((client_field->extension= static_cast<MARIADB_FIELD_EXTENSION*>(ext)))
ext->copy_extended_metadata(field_alloc, server_field);
}
else
{
client_field->extension= NULL;
}
if (IS_NUM(client_field->type))
client_field->flags|= NUM_FLAG;