3361
MySQLERRORNotableQuery ExecutionHIGH confidence

FULLTEXT search not allowed with ROLLUP

Production Risk

Low — query fails at parse/execution time; no data is modified.

How to reproduce
trigger — this will error
trigger — this will error
SELECT MATCH(col) AGAINST ('term') AS score, COUNT(*) FROM t GROUP BY col WITH ROLLUP;

expected output

ERROR 3361 (HY000): FULLTEXT search is not allowed with ROLLUP.

Fix

Use subquery to separate FULLTEXT from ROLLUP

Use subquery to separate FULLTEXT from ROLLUP
SELECT col, SUM(score) FROM (SELECT col, MATCH(body) AGAINST ('term') AS score FROM t) sub GROUP BY col WITH ROLLUP;

Why this works

ROLLUP operates on the outer query which no longer directly invokes a FULLTEXT scan.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 3361 ER_FULLTEXT_WITH_ROLLUP

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MySQL errors