Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 317603 - CREATE FUNCTION StoredFunction_In (...) RETURN ... doesn't work with MySQL 5.1.39
Summary: CREATE FUNCTION StoredFunction_In (...) RETURN ... doesn't work with MySQL 5....
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-22 11:18 EDT by Yiping Zhao CLA
Modified: 2022-06-09 10:23 EDT (History)
1 user (show)

See Also:


Attachments
The patch. (4.02 KB, patch)
2010-06-23 15:37 EDT, Andrei Ilitchev CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yiping Zhao CLA 2010-06-22 11:18:07 EDT
We build stored function as following in testSetup() of org.eclipse.persistence.testing.tests.jpa.jpql.JUnitJPQLComplexTestSuite, it worked with Oracle database, but failed with MySQL 5.1.10. The stored function generated by EclipseLink is:

CREATE FUNCTION StoredFunction_In (P_IN BIGINT) RETURN BIGINT
BEGIN 
RETURN P_IN * 1000; 
END

The reason it failed on MySQL, because the return syntax for create function in MySQL is RETURNS, not RETURN. So the correct statement on MySQL will be:

CREATE FUNCTION StoredFunction_In (P_IN BIGINT) RETURNS BIGINT
BEGIN 
RETURN P_IN * 1000; 
END

The error message for the failure on MySQL is:

all: CREATE FUNCTION StoredFunction_In (
	P_IN BIGINT)
	 RETURN  BIGINT

BEGIN 
RETURN P_IN * 1000; 
END
Query: DataModifyQuery(sql="CREATE FUNCTION StoredFunction_In (
	P_IN BIGINT)
	 RETURN  BIGINT

BEGIN 
RETURN P_IN * 1000; 
END")" type="org.eclipse.persistence.exceptions.DatabaseException">Local Exception Stack: 
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.qualifier): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RETURN  BIGINT

BEGIN 
RETURN P_IN * 1000; 
END' at line 3
Error Code: 1064
Call: CREATE FUNCTION StoredFunction_In (
	P_IN BIGINT)
	 RETURN  BIGINT

BEGIN 
RETURN P_IN * 1000; 
END
Comment 1 Yiping Zhao CLA 2010-06-22 11:21:38 EDT
The jdbc driver version is: MySQL-AB JDBC Driver  Version: mysql-connector-java-5.1.10
Comment 2 Andrei Ilitchev CLA 2010-06-23 15:37:05 EDT
Created attachment 172546 [details]
The patch.

Return key word in stored function definition is now printed by the platform - RETURN by default, RETURNS on MySQLPlatform.
Comment 3 Andrei Ilitchev CLA 2010-06-23 16:00:39 EDT
Checked into trunk, 2.1.1 pending.
Comment 4 Andrei Ilitchev CLA 2010-06-24 14:39:15 EDT
Checked into 2.1.1
Comment 5 Eclipse Webmaster CLA 2022-06-09 10:14:43 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink
Comment 6 Eclipse Webmaster CLA 2022-06-09 10:23:25 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink