Bug #24412 System error: KB Stack type illegal thrown by simple SELECT statement
Submitted: 18 Nov 2006 11:22 Modified: 8 Oct 2007 3:20
Reporter: Markus KARG Email Updates:
Status: No Feedback Impact on me:
None 
Category:MaxDB Severity:S1 (Critical)
Version:7.6.0.34 OS:Linux (OpenSuSE 10.1)
Assigned to: CPU Architecture:Any

[18 Nov 2006 11:22] Markus KARG
Description:
Running the GlassFish Entity Persistence Test Suite crashes. I investigated about the cause and found out that the following problem is the cause:

final PreparedStatement s = c.prepareStatement("SELECT * FROM CMP3_EMPLOYEE t0, CMP3_SALARY t1 WHERE ((t1.SALARY = ABS(?)) AND (t1.EMP_ID = t0.EMP_ID))");
s.setInt(1, 123);
s.executeQuery();

When running that code against a MaxDB 7.6 database (containing the db schema needed for GlassFish tests), you'll get the following message EVER:

Exception in thread "main" com.sap.dbtech.jdbc.exceptions.DatabaseException: [-9211]: System error: KB Stack type illegal
	at com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:72)
	at com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:911)
	at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:570)
	at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:434)
	at com.sap.dbtech.jdbc.CallableStatementSapDB.execute(CallableStatementSapDB.java:439)
	at com.sap.dbtech.jdbc.CallableStatementSapDB.execute(CallableStatementSapDB.java:311)
	at com.sap.dbtech.jdbc.CallableStatementSapDB.executeQuery(CallableStatementSapDB.java:735)

How to repeat:
Create the db schema for GlassFish tests (contact GlassFish team for that).
Run the following small program:

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public final class Foo {
    public static final void main(final String[] args) throws Exception {
        Class.forName("com.sap.dbtech.jdbc.DriverSapDB");
        final Connection c = DriverManager.getConnection(
                "jdbc:sapdb://localhost/SCRUM", "DBA", "SQL");
        final PreparedStatement s = c
                .prepareStatement("SELECT * FROM CMP3_EMPLOYEE t0, CMP3_SALARY t1 WHERE ((t1.SALARY = ABS(?)) AND (t1.EMP_ID = t0.EMP_ID))");
        s.setInt(1, 123);
        s.executeQuery();
    }
}

Suggested fix:
Shall run without any problem.
[21 Nov 2006 17:19] Valeriy Kravchuk
Thank you for ap roblem report. Please, specify the exact vertsion of MaxDB used, 7.6.00.xx (7.6.00.34 is the latest).
[21 Nov 2006 17:39] Markus KARG
How to find out about the exact version?
When I am starting x_server it says:
X32/LINUX 7.6.00   Build 016-121-109-428
[25 Nov 2006 18:30] Markus KARG
I have updated to the latest release (7.0.0.34), dropped and recreated the database. The problem is still there. It is 100% reproducable.
[28 Nov 2006 18:53] Markus KARG
Script used to create the database.

Attachment: dbinit.sh (application/x-sh, text), 124 bytes.

[28 Nov 2006 18:54] Markus KARG
Properties used to create database.

Attachment: dbinit.maxdb (application/octet-stream, text), 211 bytes.

[28 Nov 2006 18:54] Markus KARG
Sample program that is reproducing the error.

Attachment: Foo.java (text/x-java), 885 bytes.

[28 Nov 2006 18:57] Markus KARG
Used version of MaxDB is 7.6.0.34.

I have drilled down the problem to a simple test case that produces the problems even WITHOUT the need of the GlassFish test suite:

I have attached everything (including scripts to set up an empty database, the schema, etc.) you need to reproduce the problem. See the file Foo.java. There's no magic in it, but it ALWAYS produces the following JDBC stack trace:

Exception in thread "main" com.sap.dbtech.jdbc.exceptions.DatabaseException: [-9211]: System error: KB Stack type illegal
	at com.sap.dbtech.jdbc.packet.ReplyPacket.createException(ReplyPacket.java:72)
	at com.sap.dbtech.jdbc.ConnectionSapDB.throwSQLError(ConnectionSapDB.java:946)
	at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:584)
	at com.sap.dbtech.jdbc.ConnectionSapDB.execute(ConnectionSapDB.java:454)
	at com.sap.dbtech.jdbc.CallableStatementSapDB.execute(CallableStatementSapDB.java:448)
	at com.sap.dbtech.jdbc.CallableStatementSapDB.execute(CallableStatementSapDB.java:320)
	at com.sap.dbtech.jdbc.CallableStatementSapDB.executeQuery(CallableStatementSapDB.java:744)
	at Foo.main(Foo.java:21)
[8 Sep 2007 3:20] Valeriy Kravchuk
Please, try to repeat with a newer version, 7.6.00.37, and inform about the results.
[8 Oct 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".