diff Framework/PostgreSQL/PostgreSQLStatement.cpp @ 234:d1b124d116c1

PostgreSQL index plugin handles retries for collisions between multiple writers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Apr 2021 10:50:01 +0200
parents ab96698c73a3
children f2b32d31fc99
line wrap: on
line diff
--- a/Framework/PostgreSQL/PostgreSQLStatement.cpp	Tue Apr 06 15:07:27 2021 +0200
+++ b/Framework/PostgreSQL/PostgreSQLStatement.cpp	Thu Apr 08 10:50:01 2021 +0200
@@ -278,7 +278,16 @@
                               1);
     }
 
-    if (result == NULL)
+    if (PQtransactionStatus(reinterpret_cast<PGconn*>(database_.pg_)) == PQTRANS_INERROR)
+    {
+      if (result != NULL)
+      {
+        PQclear(result);
+      }
+      
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_DatabaseCannotSerialize);
+    }
+    else if (result == NULL)
     {
       database_.ThrowException(true);
     }