Bug #74813 | QUERY REWRITE: NULL IS NOT RECOGNIZED BY THE PLUGIN AS A LITERAL | ||
---|---|---|---|
Submitted: | 12 Nov 2014 9:41 | Modified: | 16 Jan 2015 15:51 |
Reporter: | John Embretsen | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.7.6 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[12 Nov 2014 9:41]
John Embretsen
[12 Nov 2014 9:45]
John Embretsen
Posted by developer: For completeness, here is a demonstration of the combination of Prepared Statement and matching Rewriter rule: Using null with Prepared Statement + Rewriter plugin ---------------------------------------------------- If there is an enabled rule matching the given prepared statement, the statement is rewritten at prepare time and the NULL is accpeted as a literal at execution time: mysql> PREPARE newprep FROM 'SELECT * FROM BB WHERE (? <> 1) IS NULL'; Query OK, 0 rows affected, 1 warning (0.00 sec) Statement prepared mysql> SHOW WARNINGS; +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------+ | Note | 1105 | Query 'SELECT * FROM BB WHERE (? <> 1) IS NULL' rewritten to 'SELECT a AS queryrewritten FROM BB WHERE (? <> 1) IS NULL' by plugin: Rewriter. | +-------+------+-----------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) mysql> SET @literal = 1; Query OK, 0 rows affected (0.00 sec) mysql> EXECUTE newprep USING @literal; Empty set (0.00 sec) mysql> SET @literal = NULL; Query OK, 0 rows affected (0.00 sec) mysql> EXECUTE newprep USING @literal; +----------------+ | queryrewritten | +----------------+ | 1 | | 2 | +----------------+ 2 rows in set (0.00 sec) In this case it works as expected.
[17 Nov 2014 14:52]
John Embretsen
Posted by developer: Treating this as a feature request is likely fine with me, as long as the limitation will be properly documented. QA will have to implement workarounds in the tests, but it should be doable. Note that plugin end users may still see it as a bug, and not care what the underlying root cause is.
[16 Jan 2015 15:51]
Paul DuBois
Noted in 5.7.6 changelog. NULL as an expression was not recognized as a literal for calculation of Performance Schema statement digests.
[17 Feb 2015 0:54]
Paul DuBois
Noted in 5.6.24 changelog.