From 0eaefafbafac39883a8852f1d3947bdb6b1bc71e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sat, 4 Jan 2025 17:27:55 +0100 Subject: [PATCH] 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. --- mysql-test/main/vector2.result | 9 +++++++++ mysql-test/main/vector2.test | 10 ++++++++++ sql/sql_update.cc | 4 ++-- sql/table.cc | 1 + 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/vector2.result b/mysql-test/main/vector2.result index 82bdc9e1996..92678db9c14 100644 --- a/mysql-test/main/vector2.result +++ b/mysql-test/main/vector2.result @@ -386,4 +386,13 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t index NULL b 6 NULL 1 drop view v; drop table t; +# +# MDEV-35769 ER_SQL_DISCOVER_ERROR upon updating vector key column using incorrect value +# +create table t (v vector(1) not null, vector(v)); +insert into t values (0x31313131); +flush tables; +update t set v = 1; +ERROR HY000: Cannot cast 'int' as 'vector' in assignment of `test`.`t`.`v` +drop table t; # End of 11.7 tests diff --git a/mysql-test/main/vector2.test b/mysql-test/main/vector2.test index e7b5d794e65..916792277b1 100644 --- a/mysql-test/main/vector2.test +++ b/mysql-test/main/vector2.test @@ -279,4 +279,14 @@ explain select * from (select * from t) sq order by vec_distance_euclidean(b,0x3 drop view v; drop table t; +--echo # +--echo # MDEV-35769 ER_SQL_DISCOVER_ERROR upon updating vector key column using incorrect value +--echo # +create table t (v vector(1) not null, vector(v)); +insert into t values (0x31313131); +flush tables; +--error ER_ILLEGAL_PARAMETER_DATA_TYPES2_FOR_OPERATION +update t set v = 1; +drop table t; + --echo # End of 11.7 tests diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 01cfd3ef9c4..ba9d9eaa6f4 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1877,6 +1877,8 @@ int multi_update::prepare(List ¬_used_values, *values, MARK_COLUMNS_READ, 0, NULL, 0) || TABLE::check_assignability_explicit_fields(*fields, *values, ignore); + if (unlikely(error)) + DBUG_RETURN(1); ti.rewind(); while ((table_ref= ti++)) @@ -1893,8 +1895,6 @@ int multi_update::prepare(List ¬_used_values, table->file->prepare_for_modify(true, true); } } - if (unlikely(error)) - DBUG_RETURN(1); /* Save tables being updated in update_tables diff --git a/sql/table.cc b/sql/table.cc index 034e11427fe..8012e99c624 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -3647,6 +3647,7 @@ int TABLE_SHARE::init_from_sql_statement_string(THD *thd, bool write, LEX_CUSTRING frm= {0,0}; LEX_CSTRING db_backup= thd->db; DBUG_ENTER("TABLE_SHARE::init_from_sql_statement_string"); + DBUG_ASSERT(!thd->is_error()); /* Ouch. Parser may *change* the string it's working on.