From 28ee3e433eaa2df108f7cfbfceeeb40954bce13c Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Wed, 6 Aug 2025 16:52:20 +0300 Subject: [PATCH 1/2] Target Firebird binaries for Windows 8.1 and later. It is required to correctly detect Windows version at run-time. Manifest compatibility with all Windows versions starting from Win7. --- builds/win32/defs/compatibility.manifest | 19 +++++++++++++++++++ builds/win32/msvc15/FirebirdCommon.props | 3 +++ 2 files changed, 22 insertions(+) create mode 100644 builds/win32/defs/compatibility.manifest diff --git a/builds/win32/defs/compatibility.manifest b/builds/win32/defs/compatibility.manifest new file mode 100644 index 00000000000..7c39e910875 --- /dev/null +++ b/builds/win32/defs/compatibility.manifest @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/builds/win32/msvc15/FirebirdCommon.props b/builds/win32/msvc15/FirebirdCommon.props index 56c69ad71ef..f60c800e00e 100644 --- a/builds/win32/msvc15/FirebirdCommon.props +++ b/builds/win32/msvc15/FirebirdCommon.props @@ -43,5 +43,8 @@ RC_ARH_$(Platform);RC_TARGET_$(TargetName);RC_TARGET_NAME=$(TargetName);RC_TARGET_FILENAME=$(TargetFileName);%(PreprocessorDefinitions) + + ..\defs\compatibility.manifest %(AdditionalManifestFiles) + From 91826b6a35ab47b613e471e3e0c4d161229bd15d Mon Sep 17 00:00:00 2001 From: Vlad Khorsun Date: Wed, 6 Aug 2025 16:53:16 +0300 Subject: [PATCH 2/2] Fixed bug #8690 : On Windows 7 isql exits silently right after the start. --- src/isql/isql.epp | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/src/isql/isql.epp b/src/isql/isql.epp index fe32f54219c..8e09c24f535 100644 --- a/src/isql/isql.epp +++ b/src/isql/isql.epp @@ -99,6 +99,7 @@ enum literal_string_type #if defined(WIN_NT) #include +#include #endif #include "ibase.h" #include "../isql/isql.h" @@ -349,14 +350,21 @@ static int win32ReadConsole(FILE* file, CharBuffer& mbBuffer) SetConsoleMode(handle, oldMode); }); - const size_t MAX_LINE_LENGTH = MAX_USHORT; - WCHAR* wideBuf = wideBuffer->getBuffer(MAX_LINE_LENGTH, false); + // Before Windows 10, ReadConsole() can't work with relatively large input + // buffers and set ERROR_NOT_ENOUGH_MEMORY error. Thus, use initial buffer size + // twice less than for Windows 10 and handle error by reducing the buffer size. + + static size_t maxLineLength = IsWindows10OrGreater() ? MAX_USHORT : MAX_SSHORT; + WCHAR* wideBuf = wideBuffer->getBuffer(maxLineLength, false); DWORD charsRead; - if (!ReadConsoleW(handle, wideBuf, MAX_LINE_LENGTH, &charsRead, NULL)) + while (!ReadConsoleW(handle, wideBuf, maxLineLength, &charsRead, NULL)) { - fb_assert(false); - return -1; + const DWORD error = GetLastError(); + if (error == ERROR_NOT_ENOUGH_MEMORY && maxLineLength > 256) + maxLineLength -= 256; + else + Firebird::system_error::raise("ReadConsoleW", error); } if (!charsRead) @@ -764,20 +772,17 @@ static void atexit_fb_shutdown() int CLIB_ROUTINE main(int argc, char* argv[]) { -/************************************** - * - * m a i n - * - ************************************** - * - * Functional description - * This calls ISQL_main, and exists to - * isolate main which does not exist under - * MS Windows. - * - **************************************/ - - return ISQL_main(argc, argv); + try + { + return ISQL_main(argc, argv); + } + catch (const Firebird::Exception& ex) + { + Firebird::StaticStatusVector st; + ex.stuffException(st); + isc_print_status(st.begin()); + } + return 1; }