diff options
author | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-11-23 14:53:21 +0300 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-11-23 14:53:21 +0300 |
commit | d569e6dea4c451469a0c293692c3db0e963309ce (patch) | |
tree | 28596ebaf8800bb63908b9f8da3fe3eae4a238d2 | |
parent | f0820400ee427f1398034c6881c803e42cfd249e (diff) | |
download | mariadb-git-d569e6dea4c451469a0c293692c3db0e963309ce.tar.gz |
MDEV-29169 Using MATCH returns NULL for Virtual Column
Virtual column values are updated in handler in reading commands,
like ha_index_next, etc. This was missing for ha_ft_read.
handler::ha_ft_read: add table->update_virtual_fields() call
-rw-r--r-- | mysql-test/suite/innodb_fts/r/fulltext2.result | 17 | ||||
-rw-r--r-- | mysql-test/suite/innodb_fts/t/fulltext2.test | 16 | ||||
-rw-r--r-- | sql/sql_class.h | 5 |
3 files changed, 38 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb_fts/r/fulltext2.result b/mysql-test/suite/innodb_fts/r/fulltext2.result index e9a089ab80d..720dfe4ee71 100644 --- a/mysql-test/suite/innodb_fts/r/fulltext2.result +++ b/mysql-test/suite/innodb_fts/r/fulltext2.result @@ -278,3 +278,20 @@ ALTER TABLE t1 ADD d INT NULL; ALTER TABLE t1 ADD FULLTEXT(b); ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index DROP TABLE t1; +# +# MDEV-29169 Using MATCH returns NULL for Virtual Column +# +CREATE TABLE t (a TEXT DEFAULT NULL, +b TEXT AS (a), +c TEXT AS (concat(a, '1')), +d int AS (111) VIRTUAL, +FULLTEXT KEY `a` (`a`) +) ENGINE=InnoDB; +INSERT INTO t (a) VALUES ('test'); +SELECT * FROM t; +a b c d +test test test1 111 +SELECT * FROM t WHERE MATCH(a) AGAINST('test'); +a b c d +test test test1 111 +DROP TABLE t; diff --git a/mysql-test/suite/innodb_fts/t/fulltext2.test b/mysql-test/suite/innodb_fts/t/fulltext2.test index 1e3894644a0..25a4d5b24f9 100644 --- a/mysql-test/suite/innodb_fts/t/fulltext2.test +++ b/mysql-test/suite/innodb_fts/t/fulltext2.test @@ -268,3 +268,19 @@ ALTER TABLE t1 ADD d INT NULL; --error ER_INNODB_FT_WRONG_DOCID_INDEX ALTER TABLE t1 ADD FULLTEXT(b); DROP TABLE t1; + +--echo # +--echo # MDEV-29169 Using MATCH returns NULL for Virtual Column +--echo # +CREATE TABLE t (a TEXT DEFAULT NULL, + b TEXT AS (a), + c TEXT AS (concat(a, '1')), + d int AS (111) VIRTUAL, + FULLTEXT KEY `a` (`a`) +) ENGINE=InnoDB; + +INSERT INTO t (a) VALUES ('test'); +SELECT * FROM t; +SELECT * FROM t WHERE MATCH(a) AGAINST('test'); + +DROP TABLE t; diff --git a/sql/sql_class.h b/sql/sql_class.h index 9ac973dc640..5e209f56458 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -6513,8 +6513,13 @@ inline int handler::ha_ft_read(uchar *buf) { int error= ft_read(buf); if (!error) + { update_rows_read(); + if (table->vfield && buf == table->record[0]) + table->update_virtual_fields(this, VCOL_UPDATE_FOR_READ); + } + table->status=error ? STATUS_NOT_FOUND: 0; return error; } |