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
This commit is contained in:
Nikita Malyavin 2022-11-23 14:53:21 +03:00
commit d569e6dea4
3 changed files with 38 additions and 0 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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;
}