Bug #75567 MySQL Connector/NET generates incorrect SQL for LINQ 'StartsWith' queries - #2
Submitted: 21 Jan 2015 1:46 Modified: 21 Jan 2015 6:13
Reporter: Samuel Sippe Email Updates:
Status: Duplicate Impact on me:
Category:Connector / NET Severity:S3 (Non-critical)
Version:6.9.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: connector, linq, NET

[21 Jan 2015 1:46] Samuel Sippe
Closed bug "#72058 -MySQL Connector/NET generates incorrect SQL for LINQ 'StartsWith' queries" says this issue has been fixed in 6.9.5. 

ref http://bugs.mysql.com/bug.php?id=72058

Behaviour is changed but it is not correct. 

The generated sql looks like this...

WHERE `Extent1`.`QuoteNum` LIKE 'p__linq__0%'

..when it should look like this...

WHERE `Extent1`.`QuoteNum` LIKE concat(@p__linq__0, '%')

However, the problem we were trying to solve in the previous bug is performance and the updated sql causes MySql to do a table scan instead of using the index. In my tests the only way to get like to use an index is if the value is inlined instead of parameterized. A where clause with a LIKE should look something like this...

WHERE `Extent1`.`QuoteNum` LIKE 'mysearchvalue%'

...I'm not sure if it's possible to emit this or if it would have SQL injection security implications.

How to repeat:
See bug 72058

Suggested fix:
Possibly change emmited sql to e.g.

WHERE `Extent1`.`QuoteNum` LIKE 'mysearchvalue%'
[21 Jan 2015 6:13] Chiranjeevi Battula
Hello Samuel Sippe,

Thank you for the bug report.
This is duplicate of Bug #74918.