Bug 18651: Copy the row before modify the id
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 23 May 2017 13:27:31 +0000 (10:27 -0300)
committerFridolin Somers <fridolin.somers@biblibre.com>
Thu, 22 Jun 2017 07:43:17 +0000 (09:43 +0200)
commit37b02f63d8cdab77f4cffd6d38c8e67dc61d20a3
tree613f7ed534b8021d6993c221ed8c730b9abad98a
parent45bc82bb7df4f27d3a9930ee72840aba464b7268
Bug 18651: Copy the row before modify the id

If the "max(issue_id) from old_issue + 1" already exists in issues, the
move fails.

For instance we have
1, 2, 3, 4 in issues

checkin 4
1, 2, 3 in issues (AI=5)
4 in old_issues

Restart mysql => AI is reset to MAX(issue_id) => 4

checkout a new one
1, 2, 3, 4 in issues (AI=5)
4 in old_issues

checkin 4 (will get id 5 in old_issues)
1, 2, 3 in issues (AI=5)
4, 5 in old_issues

=> This works with and without this patch

Now we have
1, 2, 3 in issues (AI=5)
4, 5 in old_issues

Restart mysql => AI is reset to MAX(issue_id) => 4

checkout 2 new ones
1, 2, 3, 4, 5 in issues (AI=7)
4, 5 in old_issues

checkin 4 (4 becomes 6 in old_issues)
1, 2, 3, 5 in issues (AI=6)
4, 5, 6 in old_issues

=> This did not work without with patch
The update of the issue_id was made before the move (so in the issues
table), the PK did not allow it

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
(cherry picked from commit 79cb157b3b4bee9f1c079937bd13019c7b7f650f)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
C4/Circulation.pm