-
Type: Bug
-
Status: Resolved
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 5.4
-
Fix Version/s: 5.5
-
Tags:
-
Impact type:Content model Change
-
Upgrade notes:
The current autoincrementIdField generation does a SELECT MAX(id) FROM thetable and then inserts its value + 1.
This is not robust in cluster mode or in multi-threaded mode, as two different parallel transaction will compute the same max.
This must be replaced by a proper use of database-backed autoincrement or serial columns.
H2:
CREATE TABLE mytable(myid BIGINT AUTO_INCREMENT PRIMARY KEY, ...);
PostgreSQL:
CREATE TABLE mytable(myid SERIAL, ...);
MySQL:
CREATE TABLE mytable(myid BIGINT AUTO_INCREMENT PRIMARY KEY, ...);
SQL Server:
CREATE TABLE mytable (myid BIGINT IDENTITY PRIMARY KEY, ...);
Oracle:
CREATE TABLE mytable(myid INTEGER PRIMARY KEY, ...); / CREATE SEQUENCE mytable_IDSEQ; / CREATE TRIGGER mytable_IDTRIG BEFORE INSERT ON mytable FOR EACH ROW WHEN (NEW.myid IS NULL) BEGIN SELECT mytable_IDSEQ.NEXTVAL INTO :NEW.myid FROM DUAL; END; /