tdf#134526 Firebird: upgrade to release 3.0.11

- Removed unneeded patches [1][2][3][4].
- No changes of ODS version.
- Added patch to revert upstream commits to avoid CppunitTest_dbaccess_firebird_test,
  CppunitTest_dbaccess_hsql_binary_import, CppunitTest_dbaccess_tdf119625
  and CppunitTest_dbaccess_tdf126268 failing when building on Windows.

[1] "extern/cloop: Missing dependencies of compilations on output directories"
<https://github.com/FirebirdSQL/firebird/pull/6948>
[2] "Fix checks for null HANDLE in Windows-only code"
<https://github.com/FirebirdSQL/firebird/pull/301>
[3] "Fix warning on Win64 build"
<https://github.com/FirebirdSQL/firebird/pull/231>
[4] "Mac sandbox" <https://github.com/FirebirdSQL/firebird/pull/308>

Change-Id: I17aa4938e41bfc070317fbb92ccea10f2db4d24d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152016
Tested-by: Jenkins
Reviewed-by: Taichi Haradaguchi <20001722@ymail.ne.jp>
diff --git a/connectivity/inc/pch/precompiled_firebird_sdbc.hxx b/connectivity/inc/pch/precompiled_firebird_sdbc.hxx
index bd628cf..7860e0b 100644
--- a/connectivity/inc/pch/precompiled_firebird_sdbc.hxx
+++ b/connectivity/inc/pch/precompiled_firebird_sdbc.hxx
@@ -13,7 +13,7 @@
 manual changes will be rewritten by the next run of update_pch.sh (which presumably
 also fixes all possible problems, so it's usually better to use it).

 Generated on 2021-03-08 13:12:28 using:
 Generated on 2023-10-28 10:48:29 using:
 ./bin/update_pch connectivity firebird_sdbc --cutoff=2 --exclude:system --exclude:module --exclude:local

 If after updating build fails, use the following command to locate conflicting headers:
@@ -30,22 +30,24 @@
#endif // PCH_LEVEL >= 1
#if PCH_LEVEL >= 2
#include <osl/diagnose.h>
#include <osl/file.h>
#include <osl/file.hxx>
#include <osl/mutex.hxx>
#include <osl/process.h>
#include <osl/thread.h>
#include <osl/time.h>
#include <rtl/alloc.h>
#include <rtl/bootstrap.hxx>
#include <rtl/character.hxx>
#include <rtl/math.h>
#include <rtl/strbuf.hxx>
#include <rtl/ustrbuf.hxx>
#include <rtl/ustring.h>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
#include <sal/types.h>
#endif // PCH_LEVEL >= 2
#if PCH_LEVEL >= 3
#include <com/sun/star/embed/ElementModes.hpp>
#include <com/sun/star/io/XStream.hpp>
#include <com/sun/star/lang/IllegalArgumentException.hpp>
#include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
#include <com/sun/star/sdbc/ColumnValue.hpp>
@@ -59,10 +61,11 @@
#include <com/sun/star/uno/Reference.hxx>
#include <comphelper/comphelperdllapi.h>
#include <comphelper/sequence.hxx>
#include <comphelper/servicehelper.hxx>
#include <comphelper/types.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <resource/sharedresources.hxx>
#include <unotools/localfilehelper.hxx>
#endif // PCH_LEVEL >= 3
#if PCH_LEVEL >= 4
#include <TConnection.hxx>
diff --git a/download.lst b/download.lst
index 568b404..8921f42 100644
--- a/download.lst
+++ b/download.lst
@@ -116,8 +116,8 @@ EXPAT_TARBALL := expat-2.5.0.tar.xz
# three static lines
# so that git cherry-pick
# will not run into conflicts
FIREBIRD_SHA256SUM := acb85cedafa10ce106b1823fb236b1b3e5d942a5741e8f8435cc8ccfec0afe76
FIREBIRD_TARBALL := Firebird-3.0.7.33374-0.tar.bz2
FIREBIRD_SHA256SUM := c716fc1c788ed614050f5469e1ba0ff442c2f1f7b907a2c808a8bac1dc3d6f83
FIREBIRD_TARBALL := Firebird-3.0.11.33703-0.tar.bz2
# three static lines
# so that git cherry-pick
# will not run into conflicts
diff --git a/external/firebird/0001-Fix-checks-for-null-HANDLE-in-Windows-only-code.patch.1 b/external/firebird/0001-Fix-checks-for-null-HANDLE-in-Windows-only-code.patch.1
deleted file mode 100644
index 22cc1e1..0000000
--- a/external/firebird/0001-Fix-checks-for-null-HANDLE-in-Windows-only-code.patch.1
+++ /dev/null
@@ -1,41 +0,0 @@
From f4c0aa3ba070e5c3ce996b33a31323a3a6820f0c Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Wed, 2 Dec 2020 10:44:28 +0100
Subject: Fix checks for null HANDLE in Windows-only code

clang-cl failed with "error: unordered comparison between pointer and zero
('HANDLE' (aka 'void *') and 'int')" in these two places introduced with
f219283b72ab537c2b5938222708f35227c1ebde "Sub-task CORE-4463: Windows
implementation for CORE-4462 (Make it possible to restore compressed .nbk files
without explicitly decompressing them)" and
c2cfa7824189ed7c3e5a19721effdf97c07dadfd "Prevent child process hung if it
writes too much data to the pipe and overflow the pipe buffer".
---
 src/utilities/nbackup/nbackup.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/utilities/nbackup/nbackup.cpp b/src/utilities/nbackup/nbackup.cpp
index 6598b6e331..4703079d67 100644
--- a/src/utilities/nbackup/nbackup.cpp
+++ b/src/utilities/nbackup/nbackup.cpp
@@ -385,7 +385,7 @@ FB_SIZE_T NBackup::read_file(FILE_HANDLE &file, void *buffer, FB_SIZE_T bufsize)
 #ifdef WIN_NT
 		// Read child's stderr often to prevent child process hung if it writes
 		// too much data to the pipe and overflow the pipe buffer.
-		const bool checkChild = (childStdErr > 0 && file == backup);
+		const bool checkChild = (childStdErr != 0 && file == backup);
 		if (checkChild)
 			print_child_stderr();
 
@@ -790,7 +790,7 @@ void NBackup::close_backup()
 		return;
 #ifdef WIN_NT
 	CloseHandle(backup);
-	if (childId > 0)
+	if (childId != 0)
 	{
 		const bool killed = (WaitForSingleObject(childId, 5000) != WAIT_OBJECT_0);
 		if (killed)
-- 
2.28.0

diff --git a/external/firebird/0001-Fix-warning-on-Win64-build-231.patch.1 b/external/firebird/0001-Fix-warning-on-Win64-build-231.patch.1
deleted file mode 100644
index 0e21f9e..0000000
--- a/external/firebird/0001-Fix-warning-on-Win64-build-231.patch.1
+++ /dev/null
@@ -1,37 +0,0 @@
From 60cb8e07b17ad8533d7d13f52435aa11e48f4659 Mon Sep 17 00:00:00 2001
From: Dimitry Sibiryakov <sd@ibphoenix.com>
Date: Tue, 12 Nov 2019 13:42:49 +0100
Subject: [PATCH] Fix warning on Win64 build (#231)

---
 src/common/ThreadStart.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/common/ThreadStart.cpp b/src/common/ThreadStart.cpp
index 184c93a32b..758056432f 100644
--- a/src/common/ThreadStart.cpp
+++ b/src/common/ThreadStart.cpp
@@ -309,13 +309,16 @@ Thread Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Han
 	 * Advanced Windows by Richter pg. # 109. */
 
 	unsigned thread_id;
-	unsigned long real_handle =
-		_beginthreadex(NULL, 0, THREAD_ENTRYPOINT, THREAD_ARG, CREATE_SUSPENDED, &thread_id);
-	if (!real_handle)
+	HANDLE handle =
+		reinterpret_cast<HANDLE>(_beginthreadex(NULL, 0, THREAD_ENTRYPOINT, THREAD_ARG, CREATE_SUSPENDED, &thread_id));
+	if (!handle)
 	{
+		// Though MSDN says that _beginthreadex() returns error in errno,
+		// GetLastError() still works because RTL call no other system
+		// functions after CreateThread() in the case of error.
+		// Watch out if it is ever changed.
 		Firebird::system_call_failed::raise("_beginthreadex", GetLastError());
 	}
-	HANDLE handle = reinterpret_cast<HANDLE>(real_handle);
 
 	SetThreadPriority(handle, priority);
 
-- 
2.20.1

diff --git a/external/firebird/0001-Revert-Backported-fix-for-7122-Invalid-state-of-mapp.patch.1 b/external/firebird/0001-Revert-Backported-fix-for-7122-Invalid-state-of-mapp.patch.1
new file mode 100644
index 0000000..625ab20
--- /dev/null
+++ b/external/firebird/0001-Revert-Backported-fix-for-7122-Invalid-state-of-mapp.patch.1
@@ -0,0 +1,180 @@
From f1d64f5eb4569fe722f312d84a3c084c2255e03f Mon Sep 17 00:00:00 2001
From: Taichi Haradaguchi <20001722@ymail.ne.jp>
Date: Wed, 22 Nov 2023 21:34:00 +0900
Subject: [PATCH] Revert "Backported fix for #7122: Invalid state of mapping
 cache after replacement of database"

This reverts commit 585b2d133a3891b58b7aeb4ddd3ccd124168abf0.
---
 src/include/consts_pub.h          |  1 -
 src/include/gen/Firebird.pas      |  1 -
 src/jrd/Mapping.h                 |  2 +-
 src/jrd/jrd.cpp                   | 14 --------------
 src/jrd/shut.cpp                  |  7 -------
 src/utilities/nbackup/nbackup.cpp | 14 +-------------
 6 files changed, 2 insertions(+), 37 deletions(-)

diff --git a/src/include/consts_pub.h b/src/include/consts_pub.h
index 769a3e372b..6107e0975a 100644
--- a/src/include/consts_pub.h
+++ b/src/include/consts_pub.h
@@ -123,7 +123,6 @@
 #define isc_dpb_nolinger				  88
 #define isc_dpb_reset_icu				  89
 #define isc_dpb_map_attach                90
-#define isc_dpb_clear_map                 96
 
 /**************************************************/
 /* clumplet tags used inside isc_dpb_address_path */
diff --git a/src/include/gen/Firebird.pas b/src/include/gen/Firebird.pas
index a891103b53..66be146060 100644
--- a/src/include/gen/Firebird.pas
+++ b/src/include/gen/Firebird.pas
@@ -3233,7 +3233,6 @@ const
 	isc_dpb_nolinger = byte(88);
 	isc_dpb_reset_icu = byte(89);
 	isc_dpb_map_attach = byte(90);
-	isc_dpb_clear_map = byte(96);
 	isc_dpb_address = byte(1);
 	isc_dpb_addr_protocol = byte(1);
 	isc_dpb_addr_endpoint = byte(2);
diff --git a/src/jrd/Mapping.h b/src/jrd/Mapping.h
index b5e068d5a0..3ab1c70c92 100644
--- a/src/jrd/Mapping.h
+++ b/src/jrd/Mapping.h
@@ -44,7 +44,7 @@ bool mapUser(Firebird::string& name, Firebird::string& trusted_role, Firebird::s
 void clearMap(const char* dbName);
 void shutdownMappingIpc();
 
-class GlobalMappingScan : public VirtualTableScan
+class GlobalMappingScan: public VirtualTableScan
 {
 public:
 	GlobalMappingScan(CompilerScratch* csb, const Firebird::string& alias,
diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp
index 43be48c5a6..4200780aa6 100644
--- a/src/jrd/jrd.cpp
+++ b/src/jrd/jrd.cpp
@@ -958,7 +958,6 @@ public:
 	bool	dpb_reset_icu;
 	bool	dpb_map_attach;
 	ULONG	dpb_remote_flags;
-	bool	dpb_clear_map;
 
 	// here begin compound objects
 	// for constructor to work properly dpb_user_name
@@ -1473,12 +1472,6 @@ JAttachment* JProvider::internalAttach(CheckStatusWrapper* user_status, const ch
 			if (ISC_check_if_remote(expanded_name, true))
 				ERR_post(Arg::Gds(isc_unavailable));
 
-			// Clear old mapping cache data on request.
-			// Unfortunately have to do it w/o access rights check - to check access rights engine
-			// needs correct mapping which sometimes can't be guaranteed before cleaning cache.
-			if (options.dpb_clear_map)
-				clearMap(expanded_name.c_str());
-
 			// Check for correct credentials supplied
 			if (existingId)
 				userId = *existingId;
@@ -2726,9 +2719,6 @@ JAttachment* JProvider::createDatabase(CheckStatusWrapper* user_status, const ch
 
 			dbb->dbb_tip_cache = FB_NEW_POOL(*dbb->dbb_permanent) TipCache(dbb);
 
-			// Clear old mapping cache data (if present)
-			clearMap(dbb->dbb_filename.c_str());
-
 			// Initialize backup difference subsystem. This must be done before WAL and shadowing
 			// is enabled because nbackup it is a lower level subsystem
 			dbb->dbb_backup_manager = FB_NEW_POOL(*dbb->dbb_permanent) BackupManager(tdbb,
@@ -6043,10 +6033,6 @@ void DatabaseOptions::get(const UCHAR* dpb, USHORT dpb_length, bool& invalid_cli
 			getString(rdr, dpb_config);
 			break;
 
-		case isc_dpb_clear_map:
-			dpb_clear_map = rdr.getBoolean();
-			break;
-
 		default:
 			break;
 		}
diff --git a/src/jrd/shut.cpp b/src/jrd/shut.cpp
index acfd5e136d..9783e2cab3 100644
--- a/src/jrd/shut.cpp
+++ b/src/jrd/shut.cpp
@@ -26,7 +26,6 @@
 #include "../jrd/scl.h"
 #include "../jrd/nbak.h"
 #include "../jrd/ods.h"
-#include "../jrd/Mapping.h"
 #include "../jrd/cch_proto.h"
 #include "../jrd/cmp_proto.h"
 #include "../jrd/err_proto.h"
@@ -223,9 +222,6 @@ void SHUT_database(thread_db* tdbb, SSHORT flag, SSHORT delay, Sync* guard)
 		check_backup_state(tdbb);
 	}
 
-	// Clear old mapping cache data (if present)
-	clearMap(dbb->dbb_filename.c_str());
-
 	attachment->att_flags |= ATT_shutdown_manager;
 
 	// Database is being shutdown. First notification gives shutdown type and delay in seconds.
@@ -409,9 +405,6 @@ void SHUT_online(thread_db* tdbb, SSHORT flag, Sync* guard)
 		check_backup_state(tdbb);
 	}
 
-	// Clear old mapping cache data (if present)
-	clearMap(dbb->dbb_filename.c_str());
-
 	// Reset shutdown flag on database header page
 
 	WIN window(HEADER_PAGE_NUMBER);
diff --git a/src/utilities/nbackup/nbackup.cpp b/src/utilities/nbackup/nbackup.cpp
index e5384bf67a..4703079d67 100644
--- a/src/utilities/nbackup/nbackup.cpp
+++ b/src/utilities/nbackup/nbackup.cpp
@@ -281,7 +281,7 @@ public:
 		username(_username), role(_role), password(_password),
 		run_db_triggers(_run_db_triggers), direct_io(_direct_io),
 		dbase(0), backup(0), decompress(_deco), childId(0), db_size_pages(0),
-		m_odsNumber(0), m_silent(false), m_printed(false), m_flash_map(false)
+		m_odsNumber(0), m_silent(false), m_printed(false)
 	{
 		// Recognition of local prefix allows to work with
 		// database using TCP/IP loopback while reading file locally.
@@ -347,7 +347,6 @@ private:
 	USHORT m_odsNumber;
 	bool m_silent;		// are we already handling an exception?
 	bool m_printed;		// pr_error() was called to print status vector
-	bool m_flash_map;	// clear mapping cache on attach
 
 	// IO functions
 	FB_SIZE_T read_file(FILE_HANDLE &file, void *buffer, FB_SIZE_T bufsize);
@@ -954,9 +953,6 @@ void NBackup::attach_database()
 	if (!run_db_triggers)
 		dpb.insertByte(isc_dpb_no_db_triggers, 1);
 
-	if (m_flash_map)
-		dpb.insertByte(isc_dpb_clear_map, 1);
-
 	if (m_silent)
 	{
 		ISC_STATUS_ARRAY temp;
@@ -1578,14 +1574,6 @@ void NBackup::restore_database(const BackupFiles& files)
 				{
 					close_database();
 					fixup_database();
-
-					m_silent = true;
-					m_flash_map = true;
-					run_db_triggers = false;
-
-					attach_database();
-					detach_database();
-
 					delete[] page_buffer;
 					return;
 				}
-- 
2.42.1

diff --git a/external/firebird/0001-extern-cloop-Missing-dependencies-of-compilations-on.patch.1 b/external/firebird/0001-extern-cloop-Missing-dependencies-of-compilations-on.patch.1
deleted file mode 100644
index a59e70e..0000000
--- a/external/firebird/0001-extern-cloop-Missing-dependencies-of-compilations-on.patch.1
+++ /dev/null
@@ -1,41 +0,0 @@
From 8305b41bb262b6e249f2551639fa88392e152287 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann <sbergman@redhat.com>
Date: Tue, 7 Sep 2021 08:47:32 +0200
Subject: [PATCH] extern/cloop: Missing dependencies of compilations on output
 directories

When building Firebird 3.0.7 as part of LibreOffice, we noticed occasional build
failures like <https://ci.libreoffice.org/job/gerrit_linux_clang_dbgutil/96392/>

> error: unable to open output file '/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/workdir/UnpackedTarball/firebird/temp/Debug/cloop/release/tests/test1/CTest.o': 'No such file or directory'
> 1 error generated.
> Makefile:72: recipe for target '/home/tdf/lode/jenkins/workspace/lo_gerrit/Config/linux_clang_dbgutil_64/workdir/UnpackedTarball/firebird/temp/Debug/cloop/release/tests/test1/CTest.o' failed

and while target "all" depends on target "mkdirs" (which would create all those
directories) in extern/cloop/Makefile, there is no order among the dependencies
of "all", so no guarantee that the directories are already created when the
compilation recipes are executed.
---
 extern/cloop/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/extern/cloop/Makefile b/extern/cloop/Makefile
index 3fca0c7356..c5a2b52628 100644
--- a/extern/cloop/Makefile
+++ b/extern/cloop/Makefile
@@ -54,10 +54,10 @@ vpath %.c $(SRC_DIRS)
 vpath %.cpp $(SRC_DIRS)
 
 define compile
-$1/%.o: %.c
+$1/%.o: %.c | $1
 	$(CC) -c $$(C_FLAGS) $$< -o $$@
 
-$1/%.o: %.cpp
+$1/%.o: %.cpp | $1
 	$(CXX) -c $$(CXX_FLAGS) $$< -o $$@
 endef
 
-- 
2.31.1

diff --git a/external/firebird/ExternalPackage_firebird.mk b/external/firebird/ExternalPackage_firebird.mk
index 2416c13..895f3d3 100644
--- a/external/firebird/ExternalPackage_firebird.mk
+++ b/external/firebird/ExternalPackage_firebird.mk
@@ -15,10 +15,10 @@ ifeq ($(OS),WNT)
$(eval $(call gb_ExternalPackage_add_file,firebird,$(LIBO_LIB_FOLDER)/ifbclient.dll,gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird/bin/ifbclient.dll))
$(eval $(call gb_ExternalPackage_add_file,firebird,$(LIBO_LIB_FOLDER)/Engine12.dll,gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird/plugins/Engine12.dll))
else ifeq ($(OS),MACOSX)
$(eval $(call gb_ExternalPackage_add_file,firebird,$(LIBO_LIB_FOLDER)/libfbclient.dylib.3.0.7,gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird/lib/libfbclient.dylib.3.0.7))
$(eval $(call gb_ExternalPackage_add_file,firebird,$(LIBO_LIB_FOLDER)/libfbclient.dylib.3.0.11,gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird/lib/libfbclient.dylib.3.0.11))
$(eval $(call gb_ExternalPackage_add_file,firebird,$(LIBO_LIB_FOLDER)/libEngine12.dylib,gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird/plugins/libEngine12.dylib))
else ifeq ($(DISABLE_DYNLOADING),)
$(eval $(call gb_ExternalPackage_add_file,firebird,$(LIBO_LIB_FOLDER)/libfbclient.so.2,gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird/lib/libfbclient.so.3.0.7))
$(eval $(call gb_ExternalPackage_add_file,firebird,$(LIBO_LIB_FOLDER)/libfbclient.so.2,gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird/lib/libfbclient.so.3.0.11))
$(eval $(call gb_ExternalPackage_add_file,firebird,$(LIBO_LIB_FOLDER)/libEngine12.so,gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird/plugins/libEngine12.so))
endif

diff --git a/external/firebird/ExternalProject_firebird.mk b/external/firebird/ExternalProject_firebird.mk
index 29a7176..5b39fd8 100644
--- a/external/firebird/ExternalProject_firebird.mk
+++ b/external/firebird/ExternalProject_firebird.mk
@@ -23,7 +23,7 @@ $(eval $(call gb_ExternalProject_register_targets,firebird,\
))

firebird_BUILDDIR = $(EXTERNAL_WORKDIR)/gen/$(if $(ENABLE_DEBUG),Debug,Release)/firebird
firebird_VERSION := 3.0.7
firebird_VERSION := 3.0.11

$(call gb_ExternalProject_get_state_target,firebird,build):
	$(call gb_Trace_StartRange,firebird,EXTERNAL)
diff --git a/external/firebird/UnpackedTarball_firebird.mk b/external/firebird/UnpackedTarball_firebird.mk
index 1f76870..c7d9a88 100644
--- a/external/firebird/UnpackedTarball_firebird.mk
+++ b/external/firebird/UnpackedTarball_firebird.mk
@@ -21,15 +21,12 @@ $(eval $(call gb_UnpackedTarball_update_autoconf_configs,firebird,\
# * external/firebird/0001-Make-comparison-operator-member-functions-const.patch.1 is upstream at
#   <https://github.com/FirebirdSQL/firebird/pull/227> "Make comparison operator member functions
#   const";
# * external/firebird/0001-Fix-checks-for-null-HANDLE-in-Windows-only-code.patch.1 is upstream at
#   <https://github.com/FirebirdSQL/firebird/pull/301> "Fix checks for null HANDLE in Windows-only
#   code",
# * external/firebird/0001-extern-cloop-Missing-dependency-of-BIN_DIR-cloop-on-.patch.1 is upstream
#   at <https://github.com/FirebirdSQL/firebird/pull/302> "extern/cloop: Missing dependency of
#   $(BIN_DIR)/cloop on $(BIN_DIR)",
# * external/firebird/0001-extern-cloop-Missing-dependencies-of-compilations-on.patch.1 is upstream
#   at <https://github.com/FirebirdSQL/firebird/pull/6948> "extern/cloop: Missing dependencies of
#   compilations on output directories":
# * external/firebird/0001-Revert-Backported-fix-for-7122-Invalid-state-of-mapp.patch.1 is a revert
#   of <https://github.com/FirebirdSQL/firebird/commit/585b2d133a3891b58b7aeb4ddd3ccd124168abf0>
#   "Backported fix for #7122: Invalid state of mapping cache after replacement of database":
$(eval $(call gb_UnpackedTarball_add_patches,firebird,\
        external/firebird/firebird.disable-ib-util-not-found.patch.1 \
		external/firebird/firebird-Engine12.patch \
@@ -40,17 +37,15 @@ $(eval $(call gb_UnpackedTarball_add_patches,firebird,\
		external/firebird/asan.patch \
		external/firebird/firebird-tdf125284.patch.1 \
		external/firebird/0001-Make-comparison-operator-member-functions-const.patch.1 \
    external/firebird/0001-Fix-warning-on-Win64-build-231.patch.1 \
		external/firebird/macos-arm64.patch.0 \
    external/firebird/firebird-btyacc-add-explicit-rule.patch \
    external/firebird/firebird-307.patch.1 \
    external/firebird/0001-Fix-checks-for-null-HANDLE-in-Windows-only-code.patch.1 \
    external/firebird/0001-extern-cloop-Missing-dependency-of-BIN_DIR-cloop-on-.patch.1 \
    external/firebird/msvc.patch \
    external/firebird/wnt-per-process-trace-storage.patch.1 \
    external/firebird/0001-extern-cloop-Missing-dependencies-of-compilations-on.patch.1 \
    external/firebird/configure-c99.patch \
    external/firebird/Wincompatible-function-pointer-types.patch \
	external/firebird/0001-Revert-Backported-fix-for-7122-Invalid-state-of-mapp.patch.1 \
))

ifeq ($(OS),WNT)
@@ -68,12 +63,6 @@ $(eval $(call gb_UnpackedTarball_add_patches,firebird,\
))
endif

ifeq ($(ENABLE_MACOSX_SANDBOX),TRUE)
$(eval $(call gb_UnpackedTarball_add_patches,firebird,\
	external/firebird/firebird-macosx-sandbox.patch.1 \
))
endif

ifneq ($(filter -fsanitize=%,$(CC)),)
$(eval $(call gb_UnpackedTarball_add_patches,firebird, \
    external/firebird/sanitizer.patch \
diff --git a/external/firebird/asan.patch b/external/firebird/asan.patch
index 2564c54..30d4304 100644
--- a/external/firebird/asan.patch
+++ b/external/firebird/asan.patch
@@ -1,6 +1,6 @@
--- builds/posix/Makefile.in
+++ builds/posix/Makefile.in
@@ -323,8 +323,8 @@
@@ -364,8 +364,8 @@
 
 metadata.fdb:	$(RUN_ISQL) $(SRC_ROOT)/dbs/metadata.sql
 	-$(RM) $@
@@ -11,16 +11,16 @@
 	$(CHMOD) 0444 $@
 
 $(HELP_FDB):	help.fdb
@@ -333,7 +333,7 @@
@@ -374,7 +374,7 @@
 	$(CHMOD) 0444 $@
 
 help.fdb:	$(BLD_ROOT)/misc/help.gbak
-	$(RUN_GBAK) -MODE read_only -R $< $@
+	$(LIBO_TUNNEL_LIBRARY_PATH) $(RUN_GBAK) -MODE read_only -R $< $@
-	$(RUN_GBAK) -MODE read_only -replace $< $@
+	$(LIBO_TUNNEL_LIBRARY_PATH) $(RUN_GBAK) -MODE read_only -replace $< $@
 	$(CHMOD) 0444 $@
 
 $(SECURITY_FDB):	security.fdb
@@ -343,18 +343,18 @@
@@ -384,18 +384,18 @@
 security.fdb:	$(SRC_ROOT)/dbs/security.sql
 	-$(RM) $@
 	-$(RM) $(SECURITY_TMP)
@@ -46,7 +46,7 @@
 	$(TOUCH) $@
 
 
@@ -560,7 +560,7 @@
@@ -603,7 +603,7 @@
 message_file:	$(FIREBIRD_MSG)
 
 $(FIREBIRD_MSG):	$(BUILD_FILE) msg.timestamp
diff --git a/external/firebird/configure-c99.patch b/external/firebird/configure-c99.patch
index a62a63f..3b5569b 100644
--- a/external/firebird/configure-c99.patch
+++ b/external/firebird/configure-c99.patch
@@ -1,6 +1,6 @@
--- configure
+++ configure
@@ -20518,8 +20518,9 @@
@@ -20687,8 +20687,9 @@
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -9,9 +9,9 @@
-	main () {
+	int main () {
 		sem_t s;
 		exit(sem_init(&s,0,0));
 		return sem_init(&s,0,0);
 		}
@@ -21263,8 +21264,9 @@
@@ -21432,8 +21433,9 @@
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -19,10 +19,10 @@
 #include <unistd.h>
-    main () {
+    int main () {
     exit(!(sizeof(off_t) == 8));
     return !(sizeof(off_t) == 8);
   }
 _ACEOF
@@ -21478,8 +21480,9 @@
@@ -21647,8 +21649,9 @@
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -33,7 +33,7 @@
   struct s {
     char a;
     union { long long x; sem_t y; } b;
@@ -21514,7 +21517,8 @@
@@ -21683,7 +21686,8 @@
 else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
diff --git a/external/firebird/firebird-cygwin-msvc-warnings.patch b/external/firebird/firebird-cygwin-msvc-warnings.patch
index 9425224..8665b4d 100644
--- a/external/firebird/firebird-cygwin-msvc-warnings.patch
+++ b/external/firebird/firebird-cygwin-msvc-warnings.patch
@@ -47,9 +47,9 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 # Clear out dependancies files created by the gcc compiler
 # since when .o and other files are deleted the dependant
diff -ur builds/posix/make.rules builds/posix/make.rules
--- builds/posix/make.rules	2016-07-07 13:56:13.036235166 +0200
+++ builds/posix/make.rules	2016-07-07 14:31:16.116291485 +0200
@@ -92,21 +92,21 @@
--- builds/posix/make.rules	2023-11-11 16:29:34.391837300 +0900
+++ builds/posix/make.rules	2023-11-11 17:08:33.694764600 +0900
@@ -85,24 +85,24 @@
 	$(LIBO_TUNNEL_LIBRARY_PATH) $(GPRE_CURRENT) $(GPRE_FLAGS) $(firstword $<) $@
 
 
@@ -64,6 +64,10 @@ diff -ur builds/posix/make.rules builds/posix/make.rules
+$(OBJ)/%.$(OBJ_EXT): $(SRC_ROOT)/%.c
 	$(CC) $(WCFLAGS) -c $(firstword $<) -o $@
 
-$(OBJ)/%.o: $(SRC_ROOT)/%.m
+$(OBJ)/%.$(OBJ_EXT): $(SRC_ROOT)/%.m
 	$(CC) $(WCFLAGS) -c $(firstword $<) -o $@
 
-$(OBJ)/%.o: $(OBJ)/%.cpp
+$(OBJ)/%.$(OBJ_EXT): $(OBJ)/%.cpp
 	$(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@
@@ -77,15 +81,15 @@ diff -ur builds/posix/make.rules builds/posix/make.rules
 	$(CC) $(WCFLAGS) -c $(firstword $<) -o $@
 
 .SUFFIXES: .epp .e
--- builds/posix/make.shared.variables.orig	2020-11-12 19:36:29.773409900 +0100
+++ builds/posix/make.shared.variables	2020-11-12 19:37:14.976503300 +0100
--- builds/posix/make.shared.variables.orig	2023-08-03 22:46:32.000000000 +0900
+++ builds/posix/make.shared.variables	2023-11-11 17:11:03.453261500 +0900
@@ -1,5 +1,5 @@
 # Helper functions
-doObjects= $(patsubst %.y,%.o,$(patsubst %.epp,%.o,$(patsubst %.c,%.o,$(1:.cpp=.o))))
+doObjects= $(patsubst %.y,%.$(OBJ_EXT),$(patsubst %.epp,%.$(OBJ_EXT),$(patsubst %.c,%.$(OBJ_EXT),$(1:.cpp=.$(OBJ_EXT)))))
-doObjects= $(patsubst %.m,%.o,$(patsubst %.y,%.o,$(patsubst %.epp,%.o,$(patsubst %.c,%.o,$(1:.cpp=.o)))))
+doObjects= $(patsubst %.m,%.$(OBJ_EXT),$(patsubst %.y,%.$(OBJ_EXT),$(patsubst %.epp,%.$(OBJ_EXT),$(patsubst %.c,%.$(OBJ_EXT),$(1:.cpp=.$(OBJ_EXT))))))
 makeObjects= $(addprefix $(OBJ)/$(patsubst ../%,%,$(1))/,$(call doObjects,$2))
 dirFiles= $(notdir $(wildcard ../src/$(1)/*.cpp)) $(notdir $(wildcard ../src/$(1)/*.c)) \
 		  $(notdir $(wildcard ../src/$(1)/*.epp)) $(notdir $(wildcard ../src/$(1)/*.y))
 		  $(notdir $(wildcard ../src/$(1)/*.epp)) $(notdir $(wildcard ../src/$(1)/*.y)) \
--- src/include/gen/autoconfig.h.in.orig	2020-11-12 20:52:49.835722200 +0100
+++ src/include/gen/autoconfig.h.in	2020-11-12 20:53:18.148311100 +0100
@@ -773,7 +773,9 @@
@@ -163,8 +167,8 @@ diff -ur builds/posix/make.rules builds/posix/make.rules
+symtab.obj: defs.h
+verbose.obj: defs.h
+warshall.obj: defs.h
--- extern/cloop/Makefile.orig	2020-11-13 10:59:53.282923700 +0100
+++ extern/cloop/Makefile	2020-11-13 11:00:24.267079900 +0100
--- extern/cloop/Makefile.orig	2023-11-11 15:59:43.477031600 +0900
+++ extern/cloop/Makefile	2023-11-11 17:22:56.976163500 +0900
@@ -24,8 +24,8 @@
 SRCS_C := $(foreach sdir,$(SRC_DIRS),$(wildcard $(sdir)/*.c))
 SRCS_CPP := $(foreach sdir,$(SRC_DIRS),$(wildcard $(sdir)/*.cpp))
@@ -189,7 +193,7 @@ diff -ur builds/posix/make.rules builds/posix/make.rules
 	$(CXX) -c $$(CXX_FLAGS) $$< -o $$@
 endef
 
@@ -75,11 +75,11 @@
@@ -79,11 +79,11 @@
 -include $(addsuffix .d,$(basename $(OBJS_CPP)))
 
 $(BIN_DIR)/cloop$(EXE_EXT): \
@@ -206,7 +210,7 @@ diff -ur builds/posix/make.rules builds/posix/make.rules
 	| $(BIN_DIR)
 
 	$(LD) $^ -o $@
@@ -105,24 +105,24 @@
@@ -110,24 +110,24 @@
 $(SRC_DIR)/tests/test1/CppTest.cpp: $(SRC_DIR)/tests/test1/CalcCppApi.h
 
 $(BIN_DIR)/test1-c$(SHRLIB_EXT): \
@@ -250,9 +254,9 @@ diff -ur builds/posix/make.rules builds/posix/make.rules
 #ifdef _MSC_VER // don't know if this is useful for MinGW
 #define NOATOM
diff -ur builds/posix/Makefile.in.examples builds/posix/Makefile.in.examples
--- builds/posix/Makefile.in.examples	2016-07-07 13:56:13.048235166 +0200
+++ builds/posix/Makefile.in.examples	2016-07-07 14:37:36.904301682 +0200
@@ -65,9 +65,9 @@
--- builds/posix/Makefile.in.examples	2023-08-03 22:46:32.000000000 +0900
+++ builds/posix/Makefile.in.examples	2023-11-11 17:50:22.666278400 +0900
@@ -67,9 +67,9 @@
 EXAMPLES_SRC=	$(ROOT)/examples
 
 
@@ -264,7 +268,7 @@ diff -ur builds/posix/Makefile.in.examples builds/posix/Makefile.in.examples
 
 INPUT_Files   =	empddl.sql empdml.sql indexoff.sql indexon.sql \
 		job.inp lang.inp proj.inp qtr.inp
@@ -172,3 +175,6 @@
@@ -173,3 +173,6 @@
 
 $(EXAMPLES_DEST)/%.h: $(EXAMPLES_SRC)/common/%.h
 	$(CP) $^ $@
diff --git a/external/firebird/firebird-cygwin-msvc.patch b/external/firebird/firebird-cygwin-msvc.patch
index c59c614..9e73490 100644
--- a/external/firebird/firebird-cygwin-msvc.patch
+++ b/external/firebird/firebird-cygwin-msvc.patch
@@ -16,7 +16,7 @@
+++ src/misc/writeBuildNum.sh	2016-07-13 11:31:18.132820200 +0200
@@ -95,9 +95,9 @@
 createMakeVersion() {

 
 OdsH="${Root}/src/jrd/ods.h"
-Mini="/tmp/miniods.h"
-TestCpp="/tmp/test.cpp"
@@ -24,12 +24,12 @@
+Mini=$(cygpath -m "/tmp/miniods.h")
+TestCpp=$(cygpath -m "/tmp/test.cpp")
+AOut=$(cygpath -m "/tmp/a.out")

 
 grep ODS_VERSION $OdsH | grep -v ENCODE_ODS >$Mini

--- configure	2016-07-07 15:57:04.538983200 +0200
+++ configure	2016-07-13 11:31:18.132820200 +0200
@@ -21490,13 +21490,12 @@
 
--- configure	2023-11-11 02:44:14.576802800 +0900
+++ configure	2023-11-11 02:59:09.005211200 +0900
@@ -21650,11 +21650,10 @@
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 #include <stdlib.h>
@@ -40,10 +40,8 @@
-    union { long long x; sem_t y; } b;
+    long long b;
   };
   exit((int)&((struct s*)1024)->b - 1024);
   return (int)&((struct s*)1024)->b - 1024;
 }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
--- builds/make.new/config/config.h.in	2016-07-07 15:55:55.693112800 +0200
+++ builds/make.new/config/config.h.in	2016-07-08 13:38:49.994986400 +0200
@@ -211,7 +211,7 @@
@@ -122,8 +120,8 @@
 
 /*****************************************************
diff -ur builds/posix/make.defaults builds/posix/make.defaults
--- builds/posix/make.defaults	2016-07-07 13:56:13.036235166 +0200
+++ builds/posix/make.defaults	2016-07-07 14:29:52.368289242 +0200
--- builds/posix/make.defaults	2023-11-11 14:37:21.822343900 +0900
+++ builds/posix/make.defaults	2023-11-11 15:13:06.175152700 +0900
@@ -56,7 +56,7 @@
 else
   FIREBIRD=$(FB_BUILD)
@@ -155,7 +153,7 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 SHRLIB_FOREIGN_EXT=	$(SHRLIB_EXT)
 
 #_____________________________________________________________________________
@@ -201,9 +202,8 @@
@@ -201,9 +201,8 @@
 
 # Search path for libraries
 
@@ -166,7 +164,7 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 
 #_____________________________________________________________________________
 
@@ -217,9 +217,9 @@
@@ -217,9 +216,9 @@
 #
 
 #LibraryFileName=libfbclient
@@ -179,7 +177,7 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 LibraryBaseName=$(LibraryFileName).${SHRLIB_EXT}
 
 LIBFIREBIRD_FULLNAME = $(LIB)/$(LibraryFullName)
@@ -228,7 +228,7 @@
@@ -228,7 +227,7 @@
 
 # The firebird engine library name
 
@@ -188,7 +186,7 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 EngineSoName=$(EngineFileName).${SHRLIB_EXT}
 ENGINE_SONAME = $(PLUGINS)/$(EngineSoName)
 
@@ -242,7 +242,7 @@
@@ -242,7 +241,7 @@
   ifeq ($(STD_EDITLINE), true)
 	LIBEDITLINE := -l$(READLINE)
   else
@@ -197,16 +195,16 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
   endif
 endif
 
@@ -313,7 +313,7 @@
@@ -313,7 +312,7 @@
 
 LIB_LINK_SONAME= -Wl,-soname,$(1)
 LIB_LINK_MAPFILE= -Wl,--version-script,$(1)
-FIREBIRD_LIBRARY_LINK= -L$(LIB) -lfbclient $(MATHLIB)
+FIREBIRD_LIBRARY_LINK= -L$(LIB) -lifbclient $(MATHLIB)
 
 EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(LINK_EMPTY_SYMBOLS)
 EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(call LINK_DARWIN_RPATH,..) $(LINK_EMPTY_SYMBOLS)
 LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) -shared
@@ -355,7 +355,7 @@
@@ -355,7 +354,7 @@
 
 # Pay attention - we place common library into obj, not lib dir
 # It's just a set of object files, prepared to be used by ld, not an output library
@@ -215,18 +213,18 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 
 # From utilities
 CREATE_DB	= $(RBIN)/create_db$(EXEC_EXT)
--- builds/posix/Makefile.in	2016-07-07 15:56:06.459221300 +0200
+++ builds/posix/Makefile.in	2016-07-13 12:44:57.134217200 +0200
--- builds/posix/Makefile.in	2023-11-11 14:40:14.036728600 +0900
+++ builds/posix/Makefile.in	2023-11-11 15:27:30.810728700 +0900
@@ -33,7 +33,7 @@
 #		Alex Peshkoff - created single makefile based on Mark's files
 #

 
-ROOT=$(shell cd ..; pwd)
+ROOT=$(shell cygpath -m '$(shell cd ..; pwd)')

 
 include     make.defaults
 ifeq ($(CROSS_OUT), Y)
@@ -178,7 +178,7 @@
@@ -183,7 +183,7 @@
 .PHONY:	cross1 cross2 boot yvalve engine fbintl gpre utilities plugins rest codes ids examples cross_rest preliminaryCheck
 
 master_process:
@@ -235,16 +233,16 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 	$(MAKE) updateBuildNum
 	$(MAKE) export_lists
 	$(MAKE) extern
@@ -214,7 +215,7 @@
@@ -219,7 +219,7 @@
 	$(MAKE) CROSS_OUT=Y cross2

 
 cross1:
-	ln -sf $(SRC_ROOT)/include/gen/autoconfig.auto $(SRC_ROOT)/include/gen/autoconfig.h
+	cp -f $(SRC_ROOT)/include/gen/autoconfig.auto $(SRC_ROOT)/include/gen/autoconfig.h
 	$(MAKE) updateBuildNum
 	$(MAKE) export_lists
 	$(MAKE) extern
@@ -239,7 +240,7 @@
@@ -244,7 +244,7 @@
 	$(MAKE) -f Makefile.examples -C $(GEN_ROOT)/examples/
 
 cross2:
@@ -253,7 +251,7 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 	$(MAKE) prerequisites
 	$(MAKE) tommath
 	$(MAKE) yvalve
@@ -310,7 +311,7 @@
@@ -315,7 +315,7 @@
 
 # remote redirector is statically linked in main FB library
 $(LIBFIREBIRD_FULLNAME):	$(YValve_Objects) $(Remote_Client_Objects) $(COMMON_LIB)
@@ -262,7 +260,7 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 
 
 #___________________________________________________________________________
@@ -320,8 +321,8 @@
@@ -324,8 +324,8 @@
 
 engine: $(ENGINE_SONAME)
 
@@ -273,7 +271,7 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 
 
 #___________________________________________________________________________
@@ -330,8 +331,8 @@
@@ -334,8 +334,8 @@
 
 fbintl: $(LIBFBINTL_SO)
 
@@ -284,7 +282,7 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 
 
 #___________________________________________________________________________
@@ -427,12 +429,13 @@
@@ -434,12 +434,13 @@
 
 .PHONY:	firebird_server fb_lock_print fbguard fbsvcmgr fbtracemgr gbak gfix gsec gsplit gstat isql nbackup
 
@@ -295,13 +293,13 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 firebird_server:	$(FB_DAEMON)
 
-$(FB_DAEMON):	$(Remote_Server_Objects) $(COMMON_LIB)
-	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(call LINK_DARWIN_RPATH,..)
-	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS)
+$(FB_DAEMON):	$(Remote_Server_Objects) $(Remote_Client_Objects) $(COMMON_LIB)
+	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(LIB_GUI) $(call LINK_DARWIN_RPATH,..)
+	$(EXE_LINK) $(EXE_LINK_OPTIONS) $^ -o $@ $(FIREBIRD_LIBRARY_LINK) $(LINK_LIBS) $(LIB_GUI)
 
 fb_lock_print:	$(LOCKPRINT)
 
@@ -633,7 +635,7 @@
@@ -638,7 +639,7 @@
 IBASE_ExtraFiles = include/types_pub.h include/consts_pub.h dsql/sqlda_pub.h common/dsc_pub.h jrd/ibase.h jrd/inf_pub.h jrd/blr.h include/gen/iberror.h
 SRC_IBASE_ExtraFiles = $(addprefix $(SRC_ROOT)/, $(IBASE_ExtraFiles))
 MAKE_HEADER_Src = $(addprefix $(SRC_ROOT)/, misc/makeHeader.cpp)
@@ -311,14 +309,18 @@ diff -ur builds/posix/make.defaults builds/posix/make.defaults
 $(INCLUDE_DEST)/ibase.h: $(SRC_IBASE_ExtraFiles)
 	$(STATICEXE_LINK) -o $(MAKE_HEADER_Bin) $(MAKE_HEADER_Src)
diff -ur builds/posix/make.rules builds/posix/make.rules
--- builds/posix/make.rules	2016-07-07 13:56:13.036235166 +0200
+++ builds/posix/make.rules	2016-07-07 14:31:16.116291485 +0200
@@ -92,26 +92,23 @@
--- builds/posix/make.rules	2023-08-03 22:46:32.000000000 +0900
+++ builds/posix/make.rules	2023-11-11 15:41:57.592482300 +0900
@@ -92,30 +92,26 @@
 
 $(OBJ)/%.o: $(SRC_ROOT)/%.c
 	$(CC) $(WCFLAGS) -c $(firstword $<) -o $@
-	@sed $(INLINE_EDIT_SED) -e "1,2s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@)
 
 $(OBJ)/%.o: $(SRC_ROOT)/%.m
 	$(CC) $(WCFLAGS) -c $(firstword $<) -o $@
-	@sed $(INLINE_EDIT_SED) -e "1,2s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@)
 
 $(OBJ)/%.o: $(OBJ)/%.cpp
 	$(CXX) $(WCXXFLAGS) -c $(firstword $<) -o $@
-	@sed $(INLINE_EDIT_SED) -e "1,2s/:/: \$$(wildcard/" -e "\$$s/\(.*\)/\\1)/" $(patsubst %.o,%.d,$@)
@@ -373,7 +375,7 @@ diff -ur builds/posix/prefix.mingw builds/posix/prefix.mingw
+++ builds/posix/prefix.mingw	2016-07-07 14:50:54.704323046 +0200
@@ -20,8 +20,8 @@
 # 

 
 # -Wno-unused-variable is used due to unused gpre generated variables
-PROD_FLAGS=-O2  -DMINGW -Wall -Wshadow -Wundef -Wno-long-long -Wno-unused-variable -Wno-sign-compare -Wno-parentheses -Wno-switch -fmessage-length=0 -Dlint -DWIN32_LEAN_AND_MEAN -MMD -mthreads -Wno-non-virtual-dtor
-DEV_FLAGS=-ggdb -DMINGW -Wall -Wshadow -Wundef -Wno-long-long -Wno-unused-variable -Wno-sign-compare -Wno-parentheses -Wno-switch -fmessage-length=0 -Dlint -DWIN32_LEAN_AND_MEAN -MMD -mthreads -Wno-non-virtual-dtor
@@ -384,7 +386,7 @@ diff -ur builds/posix/prefix.mingw builds/posix/prefix.mingw

@@ -29,6 +29,7 @@
 LIB_LINK=$(LD)

 
 LIB_LINK_OPTIONS+=-Wl,--enable-stdcall-fixup
+LIB_PLATFORM_RPATH=

@@ -393,7 +395,7 @@ diff -ur builds/posix/prefix.mingw builds/posix/prefix.mingw
@@ -36,6 +37,9 @@
 LIB_LINK_OPTIONS+=-Wl,-s
 endif

 
+LIB_LINK_OPTIONS=
+LINK_OPTS=
+
@@ -402,13 +404,13 @@ diff -ur builds/posix/prefix.mingw builds/posix/prefix.mingw
 LIB_GUI:= -mwindows -lcomctl32 -lgdi32
@@ -55,7 +59,9 @@
 ClientLibrarySoName := $(ClientLibraryName)

 
 # Looks like MinGW 3 does not support version scripts but support def-files
-LINK_FIREBIRD_SYMBOLS = $(BLD_ROOT)/win32/defs/fbclient_s.def $(BLD_ROOT)/win32/defs/fbclient.def
+LINK_FIREBIRD_SYMBOLS = /def:$(BLD_ROOT)/win32/defs/fbclient_s.def /def:$(BLD_ROOT)/win32/defs/firebird.def
+LINK_PLUGIN_SYMBOLS = /def:$(BLD_ROOT)/win32/defs/plugin.def
+LINK_IBUTIL_SYMBOLS = /def:$(BLD_ROOT)/win32/defs/ib_util.def

 
 # This is required for newly built executable to find newly built shared
 # libraries because on Win32 there is no such thing as LD_LIBRARY_PATH
--- builds/posix/make.shared.variables	2016-07-22 17:07:46.650672300 +0200
@@ -427,7 +429,7 @@ diff -ur configure configure
@@ -3337,6 +3337,14 @@
     SHRLIB_EXT=dll
     ;;

 
+  *-*-cygwin*)
+    MAKEFILE_PREFIX=mingw
+    PLATFORM=win32
@@ -502,8 +504,8 @@ diff -ur extern/btyacc/Makefile extern/btyacc/Makefile
 #ifdef WIN32
 #include <windows.h>
 #define DLL_EXPORT __declspec(dllexport)
--- extern/cloop/Makefile	2016-07-07 15:56:28.279136300 +0200
+++ extern/cloop/Makefile	2016-07-13 16:22:38.493479800 +0200
--- extern/cloop/Makefile	2023-11-11 14:40:41.522517700 +0900
+++ extern/cloop/Makefile	2023-11-11 15:59:43.477031600 +0900
@@ -11,8 +11,8 @@
 SRC_DIR		:= src
 BUILD_DIR	:= build
@@ -544,7 +546,7 @@ diff -ur extern/btyacc/Makefile extern/btyacc/Makefile
 $(OBJ_DIRS) $(BIN_DIR) $(LIB_DIR):
 	@mkdir -p $@
 
@@ -74,7 +74,7 @@
@@ -74,7 +78,7 @@
 -include $(addsuffix .d,$(basename $(OBJS_C)))
 -include $(addsuffix .d,$(basename $(OBJS_CPP)))
 
@@ -553,7 +555,7 @@ diff -ur extern/btyacc/Makefile extern/btyacc/Makefile
 	$(OBJ_DIR)/cloop/Expr.o \
 	$(OBJ_DIR)/cloop/Generator.o \
 	$(OBJ_DIR)/cloop/Lexer.o \
@@ -83,20 +83,20 @@
@@ -84,20 +88,20 @@
 
 	$(LD) $^ -o $@
 
@@ -582,7 +584,7 @@ diff -ur extern/btyacc/Makefile extern/btyacc/Makefile
 		--uses "SysUtils" \
 		--interfaceFile $(SRC_DIR)/tests/test1/CalcPascalApi.interface.pas \
 		--implementationFile $(SRC_DIR)/tests/test1/CalcPascalApi.implementation.pas \
@@ -108,23 +108,23 @@
@@ -109,23 +113,23 @@
 	$(OBJ_DIR)/tests/test1/CalcCApi.o \
 	$(OBJ_DIR)/tests/test1/CTest.o \
 
@@ -638,9 +640,9 @@ diff -ur src/misc/makeHeader.cpp src/misc/makeHeader.cpp
 #include <unistd.h>
-//#endif
+#endif



 
 
 
--- builds/posix/Makefile.in.plugins_examples.orig	2020-11-13 18:07:52.515550600 +0100
+++ builds/posix/Makefile.in.plugins_examples	2020-11-13 18:08:33.218626500 +0100
@@ -28,7 +28,7 @@
diff --git a/external/firebird/firebird-macosx-sandbox.patch.1 b/external/firebird/firebird-macosx-sandbox.patch.1
deleted file mode 100644
index 3bf246c..0000000
--- a/external/firebird/firebird-macosx-sandbox.patch.1
+++ /dev/null
@@ -1,13 +0,0 @@
-*- Mode: Diff -*-

--- firebird/src/common/isc_s_proto.h
+++ firebird/src/common/isc_s_proto.h
@@ -37,6 +37,8 @@
 // Firebird platform-specific synchronization data structures
 
 #if defined(DARWIN)
+#define USE_POSIX_SEMAPHORE
+#define USE_SHARED_FUTEX
 #define USE_FILELOCKS
 #endif
 
diff --git a/external/firebird/firebird-macosx.patch.1 b/external/firebird/firebird-macosx.patch.1
index 676f219..c9c41c0 100644
--- a/external/firebird/firebird-macosx.patch.1
+++ b/external/firebird/firebird-macosx.patch.1
@@ -20,18 +20,7 @@
-
 #DYLD_PRINT_ENV=1
 #export DYLD_PRINT_ENV

@@ -31,8 +31,8 @@
 MACOSX_DEPLOYMENT_TARGET=10.9
 export MACOSX_DEPLOYMENT_TARGET
 
-PROD_FLAGS=-DDARWIN -pipe -O2 -MMD -fPIC -fno-common -mmacosx-version-min=10.9
-DEV_FLAGS=-ggdb -DDARWIN -pipe -MMD -fPIC -fno-omit-frame-pointer -fno-common -Wall -fno-optimize-sibling-calls -mmacosx-version-min=10.9 -Wno-non-virtual-dtor
+PROD_FLAGS=-DDARWIN -pipe -O2 -MMD -fPIC -fno-common
+DEV_FLAGS=-ggdb -DDARWIN -pipe -MMD -fPIC -fno-omit-frame-pointer -fno-common -Wall -fno-optimize-sibling-calls -Wno-non-virtual-dtor
 CXXFLAGS:=$(CXXFLAGS) -fvisibility-inlines-hidden -fvisibility=hidden -stdlib=libc++ -msse4
 
 EXE_LINK_OPTIONS:=
--- firebird.org/src/common/unicode_util.cpp	2016-07-07 13:55:55.992234709 +0200
+++ firebird/src/common/unicode_util.cpp	2016-08-10 11:25:46.422331020 +0200
@@ -63,8 +63,8 @@
diff --git a/external/firebird/sanitizer.patch b/external/firebird/sanitizer.patch
index 3707b5b..52ff5dd 100644
--- a/external/firebird/sanitizer.patch
+++ b/external/firebird/sanitizer.patch
@@ -21,7 +21,7 @@
+_ZTI*
--- builds/posix/make.defaults
+++ builds/posix/make.defaults
@@ -252,7 +252,7 @@
@@ -263,7 +263,7 @@
 # LINKER OPTIONS
 #
 
@@ -30,12 +30,12 @@
 ifeq ($(TARGET),Debug)
   UNDEF_FLAGS = $(UNDEF_PLATFORM)
 endif
@@ -291,7 +291,7 @@
@@ -315,7 +315,7 @@
 LIB_LINK_MAPFILE= -Wl,--version-script,$(1)
 FIREBIRD_LIBRARY_LINK= -L$(LIB) -lfbclient $(MATHLIB)
 
-EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(LINK_EMPTY_SYMBOLS)
+EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS)
-EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(call LINK_DARWIN_RPATH,..) $(LINK_EMPTY_SYMBOLS)
+EXE_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) $(UNDEF_FLAGS) $(LIB_PATH_OPTS) $(call LINK_DARWIN_RPATH,..)
 LIB_LINK_OPTIONS= $(LDFLAGS) $(THR_FLAGS) -shared
 
 FB_DAEMON = $(BIN)/firebird$(EXEC_EXT)
diff --git a/external/firebird/ubsan.patch b/external/firebird/ubsan.patch
index fa29610..4f55bfc 100644
--- a/external/firebird/ubsan.patch
+++ b/external/firebird/ubsan.patch
@@ -1,20 +1,20 @@
--- configure
+++ configure
@@ -21506,7 +21468,7 @@
@@ -21637,7 +21637,7 @@
     char a;
     union { long long x; sem_t y; } b;
   };
-  exit((int)&((struct s*)0)->b);
+  exit((int)&((struct s*)1024)->b - 1024);
-  return (int)&((struct s*)0)->b;
+  return (int)&((struct s*)1024)->b - 1024;
 }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -21541,7 +21503,7 @@
@@ -21672,7 +21672,7 @@
     char a;
     double b;
   };
-  exit((int)&((struct s*)0)->b);
+  exit((int)&((struct s*)1024)->b - 1024);
-  return (int)&((struct s*)0)->b;
+  return (int)&((struct s*)1024)->b - 1024;
 }
 _ACEOF
 if ac_fn_c_try_run "$LINENO"; then :
@@ -86,15 +86,6 @@
 			return *this;
 		}
 		StringType& assign(const_pointer s)
--- src/common/common.h
+++ src/common/common.h
@@ -1002,6 +1002,5 @@
 }
 
 #undef UCHAR_TYPE
-#define UCHAR_TYPE uint16_t
 
 #endif /* COMMON_COMMON_H */
--- src/common/unicode_util.cpp
+++ src/common/unicode_util.cpp
@@ -187,7 +187,7 @@