Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions mysql-test/main/vector2.result
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,71 @@ vec_totext(0x03CA397B)
select vec_distance_euclidean(0x03CA397B, vec_fromtext('[0]'));
vec_distance_euclidean(0x03CA397B, vec_fromtext('[0]'))
9.64672e35
#
# MDEV-39558 SIGSEGV in collect_indexed_vcols_for_table, memory corruption by my_copy_8bit from charset_info_st::copy_fix
#
set @old_sql_mode=@@sql_mode;
set sql_mode='';
# original case
CREATE TABLE t (c FLOAT(2,2) ZEROFILL,c2 SET('') CHARACTER SET'BINARY' COLLATE'BINARY',c3 DATE,KEY(c));
ALTER TABLE t MODIFY c2 LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
REPLACE INTO t (c,c2,c3) VALUES ('','r:$u4[Z3y[HmHZ5r{FCU*0#LJOZVb][s;rm7j3N - xca *^ kt-(LE (4UP~IC:%l9/','=DpF=s=G@=d_rqbvtsjhwtgai.N.P7u}3={qDy[Un=LPeqllXoQM % fs=&mXT=e:');
Warnings:
Warning 1366 Incorrect double value: '' for column `test`.`t`.`c` at row 1
Warning 1265 Data truncated for column 'c3' at row 1
RENAME TABLE IF EXISTS t TO t4;
CREATE TABLE t (c INT KEY,c2 VECTOR (4) NOT NULL,VECTOR INDEX (c2) M=4);
(SELECT c2 FROM t) INTERSECT ALL (SELECT c2 FROM t4);
c2
drop table t, t4;
# simplified cases
CREATE TABLE t1(c LONGTEXT);
insert INTO t1 VALUES('1234567890123456789012345678901234567890123456789012345');
CREATE TABLE t2(d VECTOR(4));
create table tmp as (SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
show create table tmp;
Table Create Table
tmp CREATE TABLE `tmp` (
`c` longblob DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
(SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
c
drop table tmp, t1, t2;
CREATE TABLE t1(c MEDIUMTEXT);
insert INTO t1 VALUES('1234567890123456789012345678901234567890123456789012345');
CREATE TABLE t2(d VECTOR(4));
create table tmp as (SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
show create table tmp;
Table Create Table
tmp CREATE TABLE `tmp` (
`c` mediumblob DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
(SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
c
drop table tmp, t1, t2;
CREATE TABLE t1(c TEXT);
insert INTO t1 VALUES('1234567890123456789012345678901234567890123456789012345');
CREATE TABLE t2(d VECTOR(4));
create table tmp as (SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
show create table tmp;
Table Create Table
tmp CREATE TABLE `tmp` (
`c` blob DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
(SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
c
drop table tmp, t1, t2;
CREATE TABLE t1(c TINYTEXT);
insert INTO t1 VALUES('1234567890123456789012345678901234567890123456789012345');
CREATE TABLE t2(d VECTOR(4));
create table tmp as (SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
show create table tmp;
Table Create Table
tmp CREATE TABLE `tmp` (
`c` vector(63) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci
(SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
c
drop table tmp, t1, t2;
set sql_mode=@old_sql_mode;
# End of 11.8 tests
64 changes: 64 additions & 0 deletions mysql-test/main/vector2.test
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,68 @@ select vec_totext(0x03CA397B);
--replace_regex /(\.\d{5})\d+/\1/
select vec_distance_euclidean(0x03CA397B, vec_fromtext('[0]'));

--echo #
--echo # MDEV-39558 SIGSEGV in collect_indexed_vcols_for_table, memory corruption by my_copy_8bit from charset_info_st::copy_fix
--echo #

set @old_sql_mode=@@sql_mode;
set sql_mode='';

--echo # original case
CREATE TABLE t (c FLOAT(2,2) ZEROFILL,c2 SET('') CHARACTER SET'BINARY' COLLATE'BINARY',c3 DATE,KEY(c));
ALTER TABLE t MODIFY c2 LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
REPLACE INTO t (c,c2,c3) VALUES ('','r:$u4[Z3y[HmHZ5r{FCU*0#LJOZVb][s;rm7j3N - xca *^ kt-(LE (4UP~IC:%l9/','=DpF=s=G@=d_rqbvtsjhwtgai.N.P7u}3={qDy[Un=LPeqllXoQM % fs=&mXT=e:');
RENAME TABLE IF EXISTS t TO t4;
CREATE TABLE t (c INT KEY,c2 VECTOR (4) NOT NULL,VECTOR INDEX (c2) M=4);
(SELECT c2 FROM t) INTERSECT ALL (SELECT c2 FROM t4);

drop table t, t4;

--echo # simplified cases
CREATE TABLE t1(c LONGTEXT);
insert INTO t1 VALUES('1234567890123456789012345678901234567890123456789012345');
CREATE TABLE t2(d VECTOR(4));

create table tmp as (SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
show create table tmp;

(SELECT * FROM t1) INTERSECT (SELECT * FROM t2);

drop table tmp, t1, t2;

CREATE TABLE t1(c MEDIUMTEXT);
insert INTO t1 VALUES('1234567890123456789012345678901234567890123456789012345');
CREATE TABLE t2(d VECTOR(4));

create table tmp as (SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
show create table tmp;

(SELECT * FROM t1) INTERSECT (SELECT * FROM t2);

drop table tmp, t1, t2;

CREATE TABLE t1(c TEXT);
insert INTO t1 VALUES('1234567890123456789012345678901234567890123456789012345');
CREATE TABLE t2(d VECTOR(4));

create table tmp as (SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
show create table tmp;

(SELECT * FROM t1) INTERSECT (SELECT * FROM t2);

drop table tmp, t1, t2;

CREATE TABLE t1(c TINYTEXT);
insert INTO t1 VALUES('1234567890123456789012345678901234567890123456789012345');
CREATE TABLE t2(d VECTOR(4));

create table tmp as (SELECT * FROM t1) INTERSECT (SELECT * FROM t2);
show create table tmp;

(SELECT * FROM t1) INTERSECT (SELECT * FROM t2);

drop table tmp, t1, t2;

set sql_mode=@old_sql_mode;

--echo # End of 11.8 tests
6 changes: 4 additions & 2 deletions sql/sql_type_vector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ const Type_handler *Type_collection_vector::aggregate_for_comparison(
if (a->type_collection() == this)
swap_variables(const Type_handler *, a, b);
if (a == &type_handler_vector || a == &type_handler_hex_hybrid ||
a == &type_handler_tiny_blob || a == &type_handler_blob ||
a == &type_handler_medium_blob || a == &type_handler_long_blob ||
a == &type_handler_tiny_blob ||
a == &type_handler_varchar || a == &type_handler_string ||
a == &type_handler_null)
return b;
if (a == &type_handler_medium_blob || a == &type_handler_blob ||
a == &type_handler_long_blob)
return a;
return NULL;
}

Expand Down