From 4e6a5ab3e92f7752bd7c0265f95d921030bfe055 Mon Sep 17 00:00:00 2001 From: chrisco484 Date: Wed, 19 Apr 2023 12:26:06 +1000 Subject: [PATCH] Fixed potential typo in passing shiftStmt instead of shiftBulkStmt in AbstractlistStore - did not resolve issue #464 Reverted JoinListStore#internalAdd to non bulk shift insertion strategy and the exception of issue #464 no longer occurs. --- .../store/rdbms/scostore/AbstractListStore.java | 4 ++-- .../store/rdbms/scostore/JoinListStore.java | 16 +++++++++------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/datanucleus/store/rdbms/scostore/AbstractListStore.java b/src/main/java/org/datanucleus/store/rdbms/scostore/AbstractListStore.java index 88cd5ffe..d8b79cf6 100644 --- a/src/main/java/org/datanucleus/store/rdbms/scostore/AbstractListStore.java +++ b/src/main/java/org/datanucleus/store/rdbms/scostore/AbstractListStore.java @@ -603,7 +603,7 @@ protected int[] internalShiftBulk(ObjectProvider op, ManagedConnection conn, boo } // Execute the statement - return sqlControl.executeStatementUpdate(ec, conn, shiftStmt, ps, executeNow); + return sqlControl.executeStatementUpdate(ec, conn, shiftBulkStmt, ps, executeNow); } finally { @@ -612,7 +612,7 @@ protected int[] internalShiftBulk(ObjectProvider op, ManagedConnection conn, boo } catch (SQLException sqle) { - throw new MappedDatastoreException(shiftStmt, sqle); + throw new MappedDatastoreException(shiftBulkStmt, sqle); } } diff --git a/src/main/java/org/datanucleus/store/rdbms/scostore/JoinListStore.java b/src/main/java/org/datanucleus/store/rdbms/scostore/JoinListStore.java index 12c40383..9ab236bf 100644 --- a/src/main/java/org/datanucleus/store/rdbms/scostore/JoinListStore.java +++ b/src/main/java/org/datanucleus/store/rdbms/scostore/JoinListStore.java @@ -260,13 +260,15 @@ else if (elementOwner != op.getObject() && op.getReferencedPC() == null) // Shift any existing elements so that we can insert the new element(s) at their position if (!atEnd && start != currentListSize) { - internalShiftBulk(op, mconn, true, start-1, shift, true); -// boolean batched = currentListSize - start > 0; -// for (int i = currentListSize - 1; i >= start; i--) -// { -// // Shift the index for this row by "shift" -// internalShift(op, mconn, batched, i, shift, (i == start)); -// } +// internalShiftBulk(op, mconn, true, start-1, shift, true); +// Revert to "one at a time" shifting to see if that fixed the bug with bulk shifting raised by me: +// https://github.com/datanucleus/datanucleus-rdbms/issues/464 + boolean batched = currentListSize - start > 0; + for (int i = currentListSize - 1; i >= start; i--) + { + // Shift the index for this row by "shift" + internalShift(op, mconn, batched, i, shift, (i == start)); + } } else {