Bug #35410 Stored function: Confusing 'order clause' in error message
Submitted: 18 Mar 2008 16:05 Modified: 19 Dec 2011 0:39
Reporter: Paul Dubois Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Errors Severity:S3 (Non-critical)
Version:5.0 and up OS:Any
Assigned to: CPU Architecture:Any
Triage: Triaged: D4 (Minor)

[18 Mar 2008 16:05] Paul Dubois
Description:
I create a stored function that refers in the body to an identifier that cannot be resolved.

The error message produced by invoking the function says something about 'order clause'.

I don't know what this means. The function has no ORDER BY clause, nor is it invoked within a statement that has an ORDER BY clause.

The error message is confusing.

How to repeat:
Test script:

use test;
DROP FUNCTION IF EXISTS test.f;
CREATE FUNCTION test.f (p_value INT) RETURNS INT DETERMINISTIC RETURN x;
SELECT test.f(1);

Result from running test script:

mysql> use test;
Database changed
mysql> DROP FUNCTION IF EXISTS test.f;
Query OK, 0 rows affected, 1 warning (0.68 sec)

mysql> CREATE FUNCTION test.f (p_value INT) RETURNS INT DETERMINISTIC RETURN x;
Query OK, 0 rows affected (0.28 sec)

mysql> SELECT test.f(1);
ERROR 1054 (42S22): Unknown column 'x' in 'order clause'
[18 Mar 2008 18:13] Sveta Smirnova
Thank you for the report.

Verified as described.
[18 Mar 2008 18:13] Sveta Smirnova
Thank you for the report.

Verified as described.
[19 Dec 2011 0:39] Paul Dubois
Noted in 5.6.5 changelog.

Stored functions could produce an error message that referred to
ORDER BY even though the offending statement within the function had
no such clause.