mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-35211: Make VEC_FromText return VECTOR type instead of VARBINARY
VEC_FROMTEXT() was incorrectly inheriting its type handler from Item_str_func, causing it to be identified as VARBINARY. This led to incorrect column types (VARBINARY instead of VECTOR) when using CREATE TABLE ... AS SELECT. This change: - Overrides type_handler() in Item_func_vec_fromtext to return type_handler_vector. - Overrides create_field_for_create_select() to ensure the field is created correctly using the vector type handler during table creation. - Adds a regression test in vector_funcs.test to verify that CREATE TABLE ... AS SELECT now correctly creates a column of type VECTOR.
This commit is contained in:
committed by
Daniel Black
parent
65ee9a7b46
commit
689cf818ff
@@ -265,4 +265,14 @@ drop table t;
|
||||
#
|
||||
select vec_distance(value(key_cache_name), 0x30303030) from information_schema.key_caches;
|
||||
ERROR HY000: Cannot determine distance type for VEC_DISTANCE, index is not found
|
||||
#
|
||||
# MDEV-35211: VEC_FromText does not return vector type but varbinary
|
||||
#
|
||||
create table t as select vec_fromtext('[1,2,3]') as v;
|
||||
show create table t;
|
||||
Table Create Table
|
||||
t CREATE TABLE `t` (
|
||||
`v` vector(3) DEFAULT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
|
||||
drop table t;
|
||||
# End of 11.8 tests
|
||||
|
||||
@@ -153,4 +153,11 @@ drop table t;
|
||||
--error ER_VEC_DISTANCE_TYPE
|
||||
select vec_distance(value(key_cache_name), 0x30303030) from information_schema.key_caches;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-35211: VEC_FromText does not return vector type but varbinary
|
||||
--echo #
|
||||
create table t as select vec_fromtext('[1,2,3]') as v;
|
||||
show create table t;
|
||||
drop table t;
|
||||
|
||||
--echo # End of 11.8 tests
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "item.h"
|
||||
#include "lex_string.h"
|
||||
#include "item_func.h"
|
||||
#include "sql_type_vector.h"
|
||||
|
||||
class Item_func_vec_distance: public Item_real_func
|
||||
{
|
||||
@@ -94,6 +95,10 @@ public:
|
||||
bool fix_length_and_dec(THD *thd) override;
|
||||
Item_func_vec_fromtext(THD *thd, Item *a);
|
||||
String *val_str(String *buf) override;
|
||||
const Type_handler *type_handler() const override
|
||||
{ return &type_handler_vector; }
|
||||
Field *create_field_for_create_select(MEM_ROOT *root, TABLE *table) override
|
||||
{ return create_table_field_from_handler(root, table); }
|
||||
LEX_CSTRING func_name_cstring() const override
|
||||
{
|
||||
static LEX_CSTRING name= { STRING_WITH_LEN("VEC_FromText") };
|
||||
|
||||
Reference in New Issue
Block a user