Mercurial > hg > orthanc-databases
comparison PostgreSQL/Plugins/PostgreSQLIndex.cpp @ 56:4f66bc893fc3
Fix Debian issue #906771
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 03 Sep 2018 16:23:20 +0200 |
parents | aacb651833f5 |
children | f4d5c2c70f98 |
comparison
equal
deleted
inserted
replaced
55:89f6f2a98016 | 56:4f66bc893fc3 |
---|---|
111 { | 111 { |
112 revision = 1; | 112 revision = 1; |
113 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); | 113 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_DatabasePatchLevel, revision); |
114 } | 114 } |
115 | 115 |
116 if (revision != 1) | |
117 { | |
118 LOG(ERROR) << "PostgreSQL plugin is incompatible with database schema revision: " << revision; | |
119 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); | |
120 } | |
121 | |
122 t.Commit(); | |
123 } | |
124 | |
125 { | |
126 PostgreSQLTransaction t(*db); | |
127 | |
116 int hasTrigram = 0; | 128 int hasTrigram = 0; |
117 if (!LookupGlobalIntegerProperty(hasTrigram, *db, t, Orthanc::GlobalProperty_HasTrigramIndex) || | 129 if (!LookupGlobalIntegerProperty(hasTrigram, *db, t, Orthanc::GlobalProperty_HasTrigramIndex) || |
118 hasTrigram != 1) | 130 hasTrigram != 1) |
119 { | 131 { |
120 /** | 132 /** |
137 "CREATE EXTENSION pg_trgm; " | 149 "CREATE EXTENSION pg_trgm; " |
138 "CREATE INDEX DicomIdentifiersIndexValues2 ON DicomIdentifiers USING gin(value gin_trgm_ops);"); | 150 "CREATE INDEX DicomIdentifiersIndexValues2 ON DicomIdentifiers USING gin(value gin_trgm_ops);"); |
139 | 151 |
140 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_HasTrigramIndex, 1); | 152 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_HasTrigramIndex, 1); |
141 LOG(WARNING) << "Trigram index has been created"; | 153 LOG(WARNING) << "Trigram index has been created"; |
154 | |
155 t.Commit(); | |
142 } | 156 } |
143 catch (Orthanc::OrthancException&) | 157 catch (Orthanc::OrthancException&) |
144 { | 158 { |
145 LOG(WARNING) << "Performance warning: Your PostgreSQL server does " | 159 LOG(WARNING) << "Performance warning: Your PostgreSQL server does " |
146 << "not support trigram matching"; | 160 << "not support trigram matching"; |
147 LOG(WARNING) << "-> Consider installing the \"pg_trgm\" extension on the " | 161 LOG(WARNING) << "-> Consider installing the \"pg_trgm\" extension on the " |
148 << "PostgreSQL server, e.g. on Debian: sudo apt install postgresql-contrib"; | 162 << "PostgreSQL server, e.g. on Debian: sudo apt install postgresql-contrib"; |
149 } | 163 } |
150 } | 164 } |
151 | |
152 if (revision != 1) | |
153 { | |
154 LOG(ERROR) << "PostgreSQL plugin is incompatible with database schema revision: " << revision; | |
155 throw Orthanc::OrthancException(Orthanc::ErrorCode_Database); | |
156 } | |
157 | |
158 t.Commit(); | |
159 } | 165 } |
160 | 166 |
161 return db.release(); | 167 return db.release(); |
162 } | 168 } |
163 | 169 |