changeset 842:99598fd743f5 pg-next-1099

merged default -> pg-next-1099
author Alain Mazy <am@orthanc.team>
date Mon, 14 Sep 2026 14:37:40 +0200
parents c86377097e82 (diff) 2ef3d2ce4905 (current diff)
children 68b52a369685
files PostgreSQL/NEWS
diffstat 2 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/PostgreSQL/NEWS	Wed Aug 19 10:09:23 2026 +0200
+++ b/PostgreSQL/NEWS	Mon Sep 14 14:37:40 2026 +0200
@@ -1,3 +1,18 @@
+Pending changes in the mainline
+===============================
+
+Changes:
+* Small update of the "DeleteResource" function to avoid a warning when multiple
+  clients are trying to delete the same resource at the same time.
+  TODO: handle migration.
+  Warning:
+  test_concurrent_uploads_same_study (Concurrency.test_concurrency.TestConcurrency.test_concurrent_uploads_same_study) ... 2025-12-05 08:04:24.133 UTC [73] ERROR:  null value in column "resourcetype" of relation "deletedresources" violates not-null constraint
+  2025-12-05 08:04:24.133 UTC [73] DETAIL:  Failing row contains (null, null).
+  2025-12-05 08:04:24.133 UTC [73] CONTEXT:  SQL statement "INSERT INTO DeletedResources VALUES (deleted_resource_row.resourceType, deleted_resource_row.publicId)"
+	PL/pgSQL function deleteresource(bigint) line 85 at SQL statement
+  2025-12-05 08:04:24.133 UTC [73] STATEMENT:  SELECT * FROM DeleteResource($1)
+
+
 Release 10.3 (2026-08-19)
 =========================
 
--- a/PostgreSQL/Plugins/SQL/PrepareIndex.sql	Wed Aug 19 10:09:23 2026 +0200
+++ b/PostgreSQL/Plugins/SQL/PrepareIndex.sql	Mon Sep 14 14:37:40 2026 +0200
@@ -260,9 +260,11 @@
     -- delete the resource itself
     DELETE FROM Resources WHERE internalId=id RETURNING * INTO deleted_resource_row;
 
-    -- keep track of the deleted resources for C++ code
-    INSERT INTO DeletedResources VALUES (deleted_resource_row.resourceType, deleted_resource_row.publicId);
-  
+    IF FOUND THEN
+        -- keep track of the deleted resources for C++ code
+        INSERT INTO DeletedResources VALUES (deleted_resource_row.resourceType, deleted_resource_row.publicId);
+    END IF;
+
     -- If this resource still has siblings, keep track of the remaining parent
     -- (a parent that must not be deleted but whose LastUpdate must be updated)
     SELECT resourceType, publicId INTO remaining_ancestor_resource_type, remaining_anncestor_public_id