# HG changeset patch # User Sebastien Jodogne # Date 1535984600 -7200 # Node ID 4f66bc893fc37937f65b8453354308757adb9692 # Parent 89f6f2a980164d6300e711be419e0f082680131a Fix Debian issue #906771 diff -r 89f6f2a98016 -r 4f66bc893fc3 PostgreSQL/NEWS --- a/PostgreSQL/NEWS Wed Aug 22 18:07:22 2018 +0200 +++ b/PostgreSQL/NEWS Mon Sep 03 16:23:20 2018 +0200 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* Fix Debian issue #906771 (Uncaught exception prevents db intialization + (likely related to pg_trgm)) * Fix: Catching exceptions in destructors diff -r 89f6f2a98016 -r 4f66bc893fc3 PostgreSQL/Plugins/PostgreSQLIndex.cpp --- a/PostgreSQL/Plugins/PostgreSQLIndex.cpp Wed Aug 22 18:07:22 2018 +0200 +++ b/PostgreSQL/Plugins/PostgreSQLIndex.cpp Mon Sep 03 16:23:20 2018 +0200 @@ -113,6 +113,18 @@ SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); } + if (revision != 1) + { + LOG(ERROR) << "PostgreSQL plugin is incompatible with database schema revision: " << revision; + throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); + } + + t.Commit(); + } + + { + PostgreSQLTransaction t(*db); + int hasTrigram = 0; if (!LookupGlobalIntegerProperty(hasTrigram, *db, t, Orthanc::GlobalProperty_HasTrigramIndex) || hasTrigram != 1) @@ -139,6 +151,8 @@ SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_HasTrigramIndex, 1); LOG(WARNING) << "Trigram index has been created"; + + t.Commit(); } catch (Orthanc::OrthancException&) { @@ -148,14 +162,6 @@ << "PostgreSQL server, e.g. on Debian: sudo apt install postgresql-contrib"; } } - - if (revision != 1) - { - LOG(ERROR) << "PostgreSQL plugin is incompatible with database schema revision: " << revision; - throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); - } - - t.Commit(); } return db.release();