From 472eb0652d7d71d8605a70b9f8f15005009ae1c9 Mon Sep 17 00:00:00 2001 From: Georgy Shelkovy Date: Tue, 28 Mar 2023 20:01:33 +0500 Subject: [PATCH] fix updating from 1.x to 2.y when y > 0 (#12) Functions in the SQL script for each diskquota 2.x version refer to the exact name of shared library, e.g. for diskquota-2.1.so. As a result, upgrade from 2.0 to 2.2 is impossible without presence of 2.1 shared library as far as each extension function validated by loading shared library and checking symbol name. This patch implement symlinks creation logic to coup this problem. Symlinks for each previous release to the latest shared library will be created. But we need to control changing of sql function during next syncs. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 011266c3..361b3cbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,3 +183,11 @@ install(PROGRAMS "cmake/install_gpdb_component" DESTINATION ".") install(FILES ${diskquota_DDL} DESTINATION "share/postgresql/extension/") install(TARGETS diskquota DESTINATION "lib/postgresql/") install(FILES ${build_info_PATH} DESTINATION ".") + +file(GLOB sql_files RELATIVE ${CMAKE_SOURCE_DIR} diskquota--2.*.sql) +list(FILTER sql_files EXCLUDE REGEX ".*--.*--.*") +list(FILTER sql_files EXCLUDE REGEX ".*diskquota--${DISKQUOTA_MAJOR_VERSION}.${DISKQUOTA_MINOR_VERSION}.*") +foreach(so IN LISTS sql_files) + string(REGEX REPLACE "^diskquota--([0-9]+)\.([0-9]+).sql$" "diskquota-\\1.\\2.so" so ${so}) + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${DISKQUOTA_BINARY_NAME}.so \"\$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/lib/postgresql/${so}\")") +endforeach()