Bug #30163 | Name confusion in Fetch Into in a Function defintion | ||
---|---|---|---|
Submitted: | 31 Jul 2007 23:21 | Modified: | 7 Aug 2007 18:50 |
Reporter: | Dave Pullin (Basic Quality Contributor) | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S3 (Non-critical) |
Version: | 5.0.27-community-nt-log, 5.0 BK, 5.1 BK | OS: | Any (fails on Linux and Windows) |
Assigned to: | Marc ALFF | CPU Architecture: | Any |
[31 Jul 2007 23:21]
Dave Pullin
[31 Jul 2007 23:27]
Dave Pullin
I appreciate that there's an obvious work around (change the variable name!) but it is very natural (and readable) to use variables with the same name as the columns you are reading them into: declare sales cursor for SELECT SKU, UNITS FROM SALES ... FETCH sales INTO SKU, UNITS Since the bug wasted a lot of time to isolate, it's worth fixing the bug so that other people dont waste that time.
[1 Aug 2007 8:38]
Sveta Smirnova
Thank you for the report. Verified as described. Can be related with Bug #5967
[1 Aug 2007 16:04]
Dave Pullin
"Can be related with Bug #5967" Yes - I now see that mysql is interpreting the 'thisname' within the SELECT statement as a reference to the declared local variable, so in fact the FETCH cur1 INTO thisname was setting thisname to its own value, rather than not setting it. Thanks for the pointer. This is therefore probably not a bug, just a symptom of a design stuck between a rock and a hard place.
[7 Aug 2007 18:50]
Konstantin Osipov
A duplicate of Bug#5967