changeset 400:897253c21208 db-protobuf

support for labels in mysql
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Apr 2023 15:43:42 +0200
parents 19bd3ee1f0b3
children a8774581adfc
files Framework/Plugins/IndexBackend.cpp MySQL/NEWS MySQL/Plugins/MySQLIndex.cpp MySQL/Plugins/MySQLIndex.h PostgreSQL/NEWS
diffstat 5 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Plugins/IndexBackend.cpp	Fri Apr 07 15:28:47 2023 +0200
+++ b/Framework/Plugins/IndexBackend.cpp	Fri Apr 07 15:43:42 2023 +0200
@@ -2632,6 +2632,12 @@
                           "INSERT OR IGNORE INTO Labels VALUES(${id}, ${label})"));
         break;
 
+      case Dialect_MySQL:
+        statement.reset(new DatabaseManager::CachedStatement(
+                          STATEMENT_FROM_HERE, manager,
+                          "INSERT IGNORE INTO Labels VALUES(${id}, ${label})"));
+        break;
+
       default:
         throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
     }
--- a/MySQL/NEWS	Fri Apr 07 15:28:47 2023 +0200
+++ b/MySQL/NEWS	Fri Apr 07 15:43:42 2023 +0200
@@ -4,7 +4,7 @@
 * Compatibility with Orthanc SDK 1.12.0 (communications between the
   Orthanc core and the database plugin using Google Protocol Buffers)
 * Upgraded dependencies for static builds (notably on Windows and LSB):
-  - openssl 3.0.1
+  - openssl 3.1.0
 
 
 Release 4.3 (2021-07-22)
--- a/MySQL/Plugins/MySQLIndex.cpp	Fri Apr 07 15:28:47 2023 +0200
+++ b/MySQL/Plugins/MySQLIndex.cpp	Fri Apr 07 15:43:42 2023 +0200
@@ -295,7 +295,27 @@
         t.Commit();
       }
 
-      if (revision != 6)
+      if (revision == 6)
+      {
+        // Added new table "Labels" since release 5.0 to deal with
+        // labels that were introduced in Orthanc 1.12.0
+        DatabaseManager::Transaction t(manager, TransactionType_ReadWrite);
+
+        t.GetDatabaseTransaction().ExecuteMultiLines(
+          "CREATE TABLE Labels(id BIGINT NOT NULL,"
+          "label VARCHAR(64) NOT NULL,"
+          "PRIMARY KEY(id, label),"
+          "CONSTRAINT Labels1 FOREIGN KEY (id) REFERENCES Resources(internalId) ON DELETE CASCADE);"
+          "CREATE INDEX LabelsIndex1 ON Labels(id);"
+          "CREATE INDEX LabelsIndex2 ON Labels(label);");
+
+        revision = 7;
+        SetGlobalIntegerProperty(manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_DatabasePatchLevel, revision);
+
+        t.Commit();
+      }
+
+      if (revision != 7)
       {
         LOG(ERROR) << "MySQL plugin is incompatible with database schema revision: " << revision;
         throw Orthanc::OrthancException(Orthanc::ErrorCode_Database);        
--- a/MySQL/Plugins/MySQLIndex.h	Fri Apr 07 15:28:47 2023 +0200
+++ b/MySQL/Plugins/MySQLIndex.h	Fri Apr 07 15:43:42 2023 +0200
@@ -80,7 +80,7 @@
     // New primitive since Orthanc 1.12.0
     virtual bool HasLabelsSupport() const ORTHANC_OVERRIDE
     {
-      return false;
+      return true;
     }
   };
 }
--- a/PostgreSQL/NEWS	Fri Apr 07 15:28:47 2023 +0200
+++ b/PostgreSQL/NEWS	Fri Apr 07 15:43:42 2023 +0200
@@ -4,7 +4,7 @@
 * Compatibility with Orthanc SDK 1.12.0 (communications between the
   Orthanc core and the database plugin using Google Protocol Buffers)
 * Upgraded dependencies for static builds (notably on Windows and LSB):
-  - openssl 3.0.1
+  - openssl 3.1.0
 
 
 Release 4.0 (2021-04-22)