# HG changeset patch # User Alain Mazy # Date 1727455750 -7200 # Node ID 58fce5aebb31b20489bcdbe6fb6b712738aad13c # Parent 523241efee57d319992e14c4017c57d323938376 fix diff -r 523241efee57 -r 58fce5aebb31 PostgreSQL/Plugins/PostgreSQLIndex.cpp --- a/PostgreSQL/Plugins/PostgreSQLIndex.cpp Fri Sep 27 14:38:40 2024 +0200 +++ b/PostgreSQL/Plugins/PostgreSQLIndex.cpp Fri Sep 27 18:49:10 2024 +0200 @@ -165,18 +165,19 @@ } int property = 0; - if (!LookupGlobalIntegerProperty(property, manager, MISSING_SERVER_IDENTIFIER, - Orthanc::GlobalProperty_HasFastCountResources) || - property != 1) - { - needToRunUpgradeV1toV2 = true; - } - if (!LookupGlobalIntegerProperty(property, manager, MISSING_SERVER_IDENTIFIER, - Orthanc::GlobalProperty_GetTotalSizeIsFast) || - property != 1) - { - needToRunUpgradeV1toV2 = true; - } + // these extensions are not installed anymore from v6.0 of the plugin (but the plugin is fast to compute the size and count the resources) + // if (!LookupGlobalIntegerProperty(property, manager, MISSING_SERVER_IDENTIFIER, + // Orthanc::GlobalProperty_HasFastCountResources) || + // property != 1) + // { + // needToRunUpgradeV1toV2 = true; + // } + // if (!LookupGlobalIntegerProperty(property, manager, MISSING_SERVER_IDENTIFIER, + // Orthanc::GlobalProperty_GetTotalSizeIsFast) || + // property != 1) + // { + // needToRunUpgradeV1toV2 = true; + // } if (!LookupGlobalIntegerProperty(property, manager, MISSING_SERVER_IDENTIFIER, Orthanc::GlobalProperty_GetLastChangeIndex) || property != 1) @@ -247,7 +248,6 @@ uint64_t PostgreSQLIndex::GetTotalCompressedSize(DatabaseManager& manager) { - // Fast version if extension "./FastTotalSize.sql" is installed uint64_t result; { @@ -275,7 +275,6 @@ uint64_t PostgreSQLIndex::GetTotalUncompressedSize(DatabaseManager& manager) { - // Fast version if extension "./FastTotalSize.sql" is installed uint64_t result; { @@ -285,7 +284,14 @@ statement.Execute(); - result = static_cast(statement.ReadInteger64(0)); + if (statement.IsNull(0)) + { + return 0; + } + else + { + result = static_cast(statement.ReadInteger64(0)); + } } // disabled because this is not alway true while transactions are being executed in READ COMITTED TRANSACTION. This is however true when no files are being delete/added @@ -653,8 +659,6 @@ uint64_t PostgreSQLIndex::GetResourcesCount(DatabaseManager& manager, OrthancPluginResourceType resourceType) { - // Optimized version thanks to the "FastCountResources.sql" extension - assert(OrthancPluginResourceType_Patient == 0 && OrthancPluginResourceType_Study == 1 && OrthancPluginResourceType_Series == 2 && @@ -669,11 +673,18 @@ statement.Execute(); - result = static_cast(statement.ReadInteger64(0)); + if (statement.IsNull(0)) + { + return 0; + } + else + { + result = static_cast(statement.ReadInteger64(0)); + } } // disabled because this is not alway true while transactions are being executed in READ COMITTED TRANSACTION. This is however true when no files are being delete/added - assert(result == IndexBackend::GetResourcesCount(manager, resourceType)); + // assert(result == IndexBackend::GetResourcesCount(manager, resourceType)); return result; }