Skip to content

Commit 0eaefaf

Browse files
committed
MDEV-35769 ER_SQL_DISCOVER_ERROR upon updating vector key column using incorrect value
return as soon as the error status is known. also, init_from_sql_statement_string() cannot be run if thd->is_error(), assert it.
1 parent cca243b commit 0eaefaf

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

mysql-test/main/vector2.result

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,4 +386,13 @@ id select_type table type possible_keys key key_len ref rows Extra
386386
1 SIMPLE t index NULL b 6 NULL 1
387387
drop view v;
388388
drop table t;
389+
#
390+
# MDEV-35769 ER_SQL_DISCOVER_ERROR upon updating vector key column using incorrect value
391+
#
392+
create table t (v vector(1) not null, vector(v));
393+
insert into t values (0x31313131);
394+
flush tables;
395+
update t set v = 1;
396+
ERROR HY000: Cannot cast 'int' as 'vector' in assignment of `test`.`t`.`v`
397+
drop table t;
389398
# End of 11.7 tests

mysql-test/main/vector2.test

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,14 @@ explain select * from (select * from t) sq order by vec_distance_euclidean(b,0x3
279279
drop view v;
280280
drop table t;
281281

282+
--echo #
283+
--echo # MDEV-35769 ER_SQL_DISCOVER_ERROR upon updating vector key column using incorrect value
284+
--echo #
285+
create table t (v vector(1) not null, vector(v));
286+
insert into t values (0x31313131);
287+
flush tables;
288+
--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION
289+
update t set v = 1;
290+
drop table t;
291+
282292
--echo # End of 11.7 tests

sql/sql_update.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,8 @@ int multi_update::prepare(List<Item> &not_used_values,
18771877
*values, MARK_COLUMNS_READ, 0, NULL, 0) ||
18781878
TABLE::check_assignability_explicit_fields(*fields, *values,
18791879
ignore);
1880+
if (unlikely(error))
1881+
DBUG_RETURN(1);
18801882

18811883
ti.rewind();
18821884
while ((table_ref= ti++))
@@ -1893,8 +1895,6 @@ int multi_update::prepare(List<Item> &not_used_values,
18931895
table->file->prepare_for_modify(true, true);
18941896
}
18951897
}
1896-
if (unlikely(error))
1897-
DBUG_RETURN(1);
18981898

18991899
/*
19001900
Save tables being updated in update_tables

sql/table.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,6 +3647,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write,
36473647
LEX_CUSTRING frm= {0,0};
36483648
LEX_CSTRING db_backup= thd->db;
36493649
DBUG_ENTER("TABLE_SHARE::init_from_sql_statement_string");
3650+
DBUG_ASSERT(!thd->is_error());
36503651

36513652
/*
36523653
Ouch. Parser may *change* the string it's working on.

0 commit comments

Comments
 (0)