Bug #44322 | stored function returns incorrect result when usin filesort or no index | ||
---|---|---|---|
Submitted: | 16 Apr 2009 13:32 | Modified: | 16 Apr 2009 18:35 |
Reporter: | Alex Zimnitski | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S3 (Non-critical) |
Version: | 5.0.27 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | FUNCTION, INDEX, stored, table |
[16 Apr 2009 13:32]
Alex Zimnitski
[16 Apr 2009 18:35]
Valeriy Kravchuk
I think this is not a bug. Our manual (http://dev.mysql.com/doc/refman/5.0/en/user-variables.html) clearly says: "The general rule is never to assign a value to a user variable in one part of a statement and use the same variable in some other part of the same statement. You might get the results you expect, but this is not guaranteed." Exactly this happens in your case: you assign @var in function and read it in SELECT that uses this function. Surely changing query execution plan (with ORDER BY) may lead to unexpected results.