Skip to content

Fix for bug #8690 : On Windows 7 isql exits silently right after the start. #8691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions builds/win32/defs/compatibility.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- compatibility.manifest -->
<!-- see https://learn.microsoft.com/en-us/windows/win32/sysinfo/targeting-your-application-at-windows-8-1 -->
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 and Windows 11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
<!-- supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/ -->
</application>
</compatibility>
</assembly>
3 changes: 3 additions & 0 deletions builds/win32/msvc15/FirebirdCommon.props
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@
<ResourceCompile>
<PreprocessorDefinitions>RC_ARH_$(Platform);RC_TARGET_$(TargetName);RC_TARGET_NAME=$(TargetName);RC_TARGET_FILENAME=$(TargetFileName);%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Manifest>
<AdditionalManifestFiles>..\defs\compatibility.manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>
</Manifest>
</ItemDefinitionGroup>
</Project>
43 changes: 24 additions & 19 deletions src/isql/isql.epp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ enum literal_string_type

#if defined(WIN_NT)
#include <windows.h>
#include <VersionHelpers.h>
#endif
#include "ibase.h"
#include "../isql/isql.h"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}


Expand Down
Loading