Hi, Thanks a lot for the test case! I could reproduce the problem now. The SQL.sql can be reduced to:
create table a(x int primary key); create table b(x int, y int, primary key(x, y)); alter table b add foreign key(x) references a(x); I used the following shell script to reproduce the error: rm testdb* rm empty.sql touch empty.sql java -cp h2-1.3.174.jar org.h2.tools.RunScript -url jdbc:h2:./testdb -script SQL.sql -user x java -cp h2-1.3.176.jar org.h2.tools.RunScript -url jdbc:h2:./testdb -script empty.sql -user x java -cp h2-1.3.176.jar org.h2.tools.RunScript -url jdbc:h2:./testdb -script empty.sql -user x I'm not sure yet what the problem is, but it looks like it's related to bugfixes for contraints (see the change log). Regards, Thomas On Fri, May 16, 2014 at 11:57 AM, Niko Paltzer <[email protected]> wrote: > I can confirm the problem. We tried to move from 1.3.172 to 1.3.174 and > got the same error. > > > > > On Friday, May 9, 2014 4:12:29 PM UTC+2, Germano Rizzo wrote: >> >> If I remove the foreign key definition (last line in the SQL) the problem >> doesn't present itself. >> >> Of course I can't do this, as I have many databases already created. I'll >> stick with 174 until this is solved. >> >> Il giorno venerdì 9 maggio 2014 15:30:07 UTC+2, Germano Rizzo ha scritto: >>> >>> Hi, >>> I have a reproducible bug with versions 174 and 176 (at least). A db >>> created with 1.3.174 (no particular settings) corrupts when just opening >>> and closing it in 1.3.176. To reproduce: >>> >>> >>> 1. download this sql (generated by the SCRIPT command from a test db >>> of mine): https://www.dropbox.com/s/gjng7vfqkpp9fio/SQL.sql >>> 2. create a blank db in 1.3.174 and restore the script; close the db >>> 3. open the db in 1.3.176, close it; >>> 4. reopen the db in 1.3.176. it will crash. >>> >>> As said, I don't use any parameter for the JDBC URL. The crash is this: >>> >>> Exception in thread "main" org.h2.jdbc.JdbcSQLException: Unique index or >>> primary key violation: "PRIMARY KEY ON """".PAGE_INDEX"; SQL statement: >>> ALTER TABLE PUBLIC.DETAILS ADD CONSTRAINT PUBLIC.FK_DETAILS FOREIGN >>> KEY(ID) REFERENCES PUBLIC.ENTITIES(ID) NOCHECK [23505-176] >>> at org.h2.message.DbException.getJdbcSQLException( >>> DbException.java:344) >>> at org.h2.message.DbException.get(DbException.java:178) >>> at org.h2.message.DbException.get(DbException.java:154) >>> at org.h2.index.PageDataIndex.getNewDuplicateKeyException( >>> PageDataIndex.java:166) >>> at org.h2.index.PageDataIndex.add(PageDataIndex.java:144) >>> at org.h2.store.PageStore.addMeta(PageStore.java:1808) >>> ... >>> >>> Here you can find the corrupted db: https://www.dropbox.com/s/ >>> e4fj39jaoqwsdom/test.h2.db >>> >>> You can use SquirrelSQL to test, or use this eclipse project: >>> https://www.dropbox.com/s/ez2lre6t7uf64vc/H2Bug.7z >>> >>> To use it: >>> >>> 1. Put only h2-1.3.174.jar in the path >>> 2. Launch DBCreate174.java >>> 3. Put only h2-1.3.176.jar in the path >>> 4. Launch DBTriggerBug176.java >>> 5. crash >>> >>> Hope this helps. Let me know if I can be of further assistance. >>> >>> Germano >>> >>> >>> >>> -- > You received this message because you are subscribed to the Google Groups > "H2 Database" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/h2-database. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "H2 Database" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
