lbehnke / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

ArrayIndexOutOfBoundsException in RowList.writeRow #187

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Before submitting a bug, please check the FAQ:
http://www.h2database.com/html/faq.html

What steps will reproduce the problem?
(simple SQL scripts or simple standalone applications are preferred)

I've included the queries which seem to show this problem.

1. Create a sample table:
CREATE TABLE MARKETORDERS (
    ORDERID BIGINT NOT NULL,
    CHARID BIGINT NOT NULL,
    STATIONID BIGINT NOT NULL,
    VOLENTERED BIGINT NOT NULL,
    VOLREMAINING BIGINT NOT NULL,
    MINVOLUME BIGINT NOT NULL,
    ORDERSTATE INT NOT NULL,
    TYPEID BIGINT NOT NULL,
    RANGE INT NOT NULL,
    ACCOUNTKEY INT NOT NULL,
    DURATION INT NOT NULL,
    ESCROW DECIMAL(20, 2) NOT NULL,
    PRICE DECIMAL(20, 2) NOT NULL,
    BID TINYINT NOT NULL,
    ISSUED TIMESTAMP NOT NULL
);

2. Run this query
UPDATE marketorders SET orderstate = 2, volremaining = 0 WHERE orderstate =
0 AND charID = 1368069062

What is the expected output? What do you see instead?
I expected this query to work, since the 'charID' column is a BIGINT(19)
datatype. In fact the value is present in the table (in my actual database,
but these rows are not needed to reproduce the error). 

If I execute the second query I get the following Exception (and I believe
this is due to the fact that 1368069062 is bigger than a signed integer):
General error: java.lang.ArrayIndexOutOfBoundsException: 2174; SQL statement:
UPDATE marketorders SET orderstate = 2, volremaining = 0 WHERE orderstate =
0 AND charID = 1368069062 [50000-119] HY000/50000 (Help)
org.h2.jdbc.JdbcSQLException: General error:
java.lang.ArrayIndexOutOfBoundsException: 2174; SQL statement:
UPDATE marketorders SET orderstate = 2, volremaining = 0 WHERE orderstate =
0 AND charID = 1368069062 [50000-119]
    at org.h2.message.Message.getSQLException(Message.java:106)
    at org.h2.message.Message.convert(Message.java:283)
    at org.h2.command.Command.executeUpdate(Command.java:228)
    at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:162)
    at org.h2.server.web.WebThread.getResult(WebThread.java:1691)
    at org.h2.server.web.WebThread.query(WebThread.java:1274)
    at org.h2.server.web.WebThread.process(WebThread.java:430)
    at org.h2.server.web.WebThread.processRequest(WebThread.java:183)
    at org.h2.server.web.WebThread.process(WebThread.java:236)
    at org.h2.server.web.WebThread.run(WebThread.java:193)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2174
    at org.h2.store.DataPage.writeInt(DataPage.java:140)
    at org.h2.result.RowList.writeRow(RowList.java:62)
    at org.h2.result.RowList.writeAllRows(RowList.java:106)
    at org.h2.result.RowList.add(RowList.java:137)
    at org.h2.command.dml.Update.update(Update.java:119)
    at org.h2.command.CommandContainer.update(CommandContainer.java:72)
    at org.h2.command.Command.executeUpdate(Command.java:208)
    ... 7 more 

What version of the product are you using? On what operating system, file
system, and virtual machine?
- h2-1.1.119.jar.
- Vista Home Premium (32 bit).
- NTFS file system.
- And no running virtual machine.

Do you know a workaround?
No, sorry.

How important/urgent is the problem for you?
The application still works, but some functionality won't work, and a lot
of keys in the database are of similar size. I think it's only a matter of
time before keys will grow to a similar size.

In your view, is this a defect or a feature request?
I checked the limits and limitations page, and I couldn't find anything
like this, so I believe this to be a defect.

Please provide any additional information below.
I appreciate your efforts towards this project. Keep up the good work. 

Original issue reported on code.google.com by websch...@gmail.com on 8 Apr 2010 at 10:05

GoogleCodeExporter commented 9 years ago
This is a known issue that was fixed in version 1.2.120. 
See http://www.h2database.com/html/changelog.html
"Large updates could throw an ArrayIndexOutOfBoundsException in 
RowList.writeRow."

Therefore, I'm resolving the issue as Fixed.

Original comment by thomas.t...@gmail.com on 16 Apr 2010 at 7:37