Hi, Can somebody confirm please if this is a real problem with H2 or not? We will need to fix this soon so if there is no official solution we will have to work around it ourselves, possibly using some other DB.
Thank you, Kristof On Wednesday, 5 April 2017 15:54:21 UTC+1, Kristof Szilagyi wrote: > > Hi, > > I've managed to break referential integrity (reaching a state which is not > correct) the following way. I am using the latest H2, I've managed to > reproduce this with H2 Console, connecting to it with the browser client > and a separate JDBC client. > These are my tables: > > CREATE TABLE "PUBLIC"."core_driver" > ( > id integer PRIMARY KEY NOT NULL, > ); > > and > > CREATE TABLE "PUBLIC"."core_jobstatus" > ( > id integer PRIMARY KEY NOT NULL, > driver_id integer NOT NULL, > ); > ALTER TABLE "PUBLIC"."core_jobstatus" > ADD CONSTRAINT core_jobstatus_driver_id_179f91138d7c8c95_fk_core_driver_id > FOREIGN KEY (driver_id) > REFERENCES "PUBLIC"."core_driver"(id); > > Checking that I can't violate the constraints by default: > > insert into "core_jobstatus" values(1, 1); -> Throws exception, all good > > So let's break it then. > > 1. Insert data: > insert into "core_driver" values(1); > 2. In session 1(auto-commit off): > begin transaction; > insert into "core_jobstatus" values(1, 1); > 3. In session 2: > delete from "core_driver"; > 4. In session 1: > commit > > No exception. Now we are in a situation where there is a record in the > core_jobstatus which references to a record in the driver table which does > not exists in the driver table. Basically the same situation which I proved > in the beginning that it violates the constraint. > Is this a bug or what am I doing wrong/how can I work around it? > > Regards, > Kristof > > > Notice: This email is confidential and may contain copyright material of > members of the Ocado Group. Opinions and views expressed in this message > may not necessarily reflect the opinions and views of the members of the > Ocado Group. > > > > If you are not the intended recipient, please notify us immediately and > delete all copies of this message. Please note that it is your > responsibility to scan this message for viruses. > > > > Fetch and Sizzle are trading names of Speciality Stores Limited and Fabled > is a trading name of Marie Claire Beauty Limited, both members of the Ocado > Group. > > > > References to the “Ocado Group” are to Ocado Group plc (registered in > England and Wales with number 7098618) and its subsidiary undertakings (as > that expression is defined in the Companies Act 2006) from time to time. > The registered office of Ocado Group plc is Titan Court, 3 Bishops Square, > Hatfield Business Park, Hatfield, Herts. AL10 9NE. > -- Notice: This email is confidential and may contain copyright material of members of the Ocado Group. Opinions and views expressed in this message may not necessarily reflect the opinions and views of the members of the Ocado Group. If you are not the intended recipient, please notify us immediately and delete all copies of this message. Please note that it is your responsibility to scan this message for viruses. Fetch and Sizzle are trading names of Speciality Stores Limited and Fabled is a trading name of Marie Claire Beauty Limited, both members of the Ocado Group. References to the “Ocado Group” are to Ocado Group plc (registered in England and Wales with number 7098618) and its subsidiary undertakings (as that expression is defined in the Companies Act 2006) from time to time. The registered office of Ocado Group plc is Titan Court, 3 Bishops Square, Hatfield Business Park, Hatfield, Herts. AL10 9NE. -- 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 https://groups.google.com/group/h2-database. For more options, visit https://groups.google.com/d/optout.
