Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: CUBRID Engine
-
Labels:
-
Fix Build Number:Apricot
Description
In my jOOQ integration tests, I'm running the following query (simplified here):
select case 1 when 1 then 'A' else 'B' end
The above query fails fatally when executed using bind values in CUBRID:
PreparedStatement s = connection.prepareStatement(
"select case ? when ? then ? else ? end");
Preparing this statement causes a system error:
cubrid.jdbc.driver.CUBRIDException: Semantic: System error (generate var) in ..\..\src\parser\xasl_generation.c (line: 8833) select case ?:0 when ?:1 then ?:2 else ?:3 end at cubrid.jdbc.driver.CUBRIDConnection.createCUBRIDException(CUBRIDConnection.java:829) at cubrid.jdbc.driver.CUBRIDConnection.prepare(CUBRIDConnection.java:583) at cubrid.jdbc.driver.CUBRIDConnection.prepare(CUBRIDConnection.java:714) at cubrid.jdbc.driver.CUBRIDConnection.prepareStatement(CUBRIDConnection.java:148) at org.jooq.impl.ConnectionProxy.prepareStatement(ConnectionProxy.java:88) at org.jooq.test._.testcases.FunctionTests.testCaseStatement(FunctionTests.java:353) at org.jooq.test.jOOQAbstractTest.testCaseStatement(jOOQAbstractTest.java:1272)
A workaround is to cast the bind variable from the "else" clause. This works for me:
PreparedStatement s = connection.prepareStatement(
"select case ? when ? then ? else cast(? as varchar) end");
s.setInt(1, 1);
s.setInt(2, 1);
s.setString(3, "A");
s.setString(4, "B");
s.executeQuery();
I don't think this is a JDBC bug. I can reproduce the same issue when running this query in the CUBRID Manager. The first one fails, the second one works
select case ?:0 when ?:1 then ?:2 else ?:3 end select case ?:0 when ?:1 then ?:2 else cast(?:3 as varchar) end

Reproduced and reported to http://bts1.nhncorp.com/nhnbts/browse/CUBRIDSUS-7525.