Mercurial > hg > orthanc-databases
comparison PostgreSQL/Plugins/PostgreSQLIndex.cpp @ 12:41543239072d
transactions for storage area
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Jul 2018 18:34:56 +0200 |
parents | 7cea966b6829 |
children | 927264a0c137 |
comparison
equal
deleted
inserted
replaced
11:0217486720b3 | 12:41543239072d |
---|---|
64 | 64 |
65 std::auto_ptr<PostgreSQLDatabase> db(new PostgreSQLDatabase(parameters_)); | 65 std::auto_ptr<PostgreSQLDatabase> db(new PostgreSQLDatabase(parameters_)); |
66 | 66 |
67 db->Open(); | 67 db->Open(); |
68 | 68 |
69 if (parameters_.HasLock()) | |
70 { | |
71 db->AdvisoryLock(42 /* some arbitrary constant */); | |
72 } | |
73 | |
69 if (clearAll_) | 74 if (clearAll_) |
70 { | 75 { |
71 db->ClearAll(); | 76 db->ClearAll(); |
72 } | 77 } |
73 | 78 |
85 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabaseSchemaVersion, expectedVersion); | 90 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabaseSchemaVersion, expectedVersion); |
86 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, 1); | 91 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, 1); |
87 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_HasTrigramIndex, 0); | 92 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_HasTrigramIndex, 0); |
88 } | 93 } |
89 | 94 |
90 t.Commit(); | |
91 } | |
92 | |
93 { | |
94 PostgreSQLTransaction t(*db); | |
95 | |
96 if (!db->DoesTableExist("Resources")) | 95 if (!db->DoesTableExist("Resources")) |
97 { | 96 { |
98 LOG(ERROR) << "Corrupted PostgreSQL database"; | 97 LOG(ERROR) << "Corrupted PostgreSQL database"; |
99 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | 98 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); |
100 } | 99 } |