ODBCQueryTool icon indicating copy to clipboard operation
ODBCQueryTool copied to clipboard

Scripting failures - :file command does not work

Open GStegemann opened this issue 1 year ago • 1 comments

Hello,

I am trying to implement a script to automate some installation steps of an Application Installer.

However, the ":file open" command does not work. No file will be created at all. If I use ":file write" or ":file append" a zero length file will be created, but the ODBCQuery crashes with exception 0xc0000374:

Name der fehlerhaften Anwendung: ODBCQueryTool.exe, Version: 3.4.1.395, Zeitstempel: 0x6590414f Name des fehlerhaften Moduls: ntdll.dll, Version: 6.1.7601.24545, Zeitstempel: 0x5e0eb751 Ausnahmecode: 0xc0000374 Fehleroffset: 0x000ceaeb ID des fehlerhaften Prozesses: 0x1114 Startzeit der fehlerhaften Anwendung: 0x01daab8c5deafc22 Pfad der fehlerhaften Anwendung: C:\Program Files (x86)\EDO\OpenODBCQuerytool\ODBCQueryTool.exe Pfad des fehlerhaften Moduls: C:\Windows\SysWOW64\ntdll.dll Berichtskennung: b6b24f22-177f-11ef-806d-000c29573c8c

Second no data is assigned to bound variables after running a Database Query:

-- Result variables
:variable1 COLUMN LONG;
:variable2 COLUMN LONG;

:select on;
select parentid,objectid from OBJECTS where classname = 'Flink' and objectname = 'HOSTXX';

The value of ":variable1" and ":variable2" is always 0. Executing the SELECT command directly in ODBCQuery delivers the expected results.

GStegemann avatar May 21 '24 14:05 GStegemann

After some testing I discovered more details.

Regarding ":file open" command:

  • removing the enclosing quotes of the filename in ":file open" creates at least an empty file and does not crash the application,
  • using double quotes to enclose the filename causes the script to stop after a line with double quotes,
  • however, every line which has strings enclosed in double quotes causes the script to exit.

Regarding variables bound to a select;

  • the variables itself seem to have the correct values, as shown in Script Variable Window. But the if statements do not work as expected.

GStegemann avatar May 21 '24 19:05 GStegemann

I found and fixed the reason for exception 0xc0000374.

In function WinFile::FormatV there is an obsolete "delete" statement:

diff --git a/BaseLibrary/WinFile.cpp b/BaseLibrary/WinFile.cpp
index 3e6afdd..7090ebf 100644
--- a/BaseLibrary/WinFile.cpp
+++ b/BaseLibrary/WinFile.cpp
@@ -1203,7 +1203,7 @@ WinFile::FormatV(LPCTSTR p_format,va_list p_list)
   CString buffer;
   buffer.FormatV(p_format,p_list);
   bool result = Write(buffer);
-  delete[] buffer;
+  // is a non heap variable! delete[] buffer;
   return result;
 }

After removing the "delete" statement scripting works regarding creating an output file and printing text to an output file.

Anyway, if the filename is not enclosed in quotes a tokenized filename will be created. E.g. ":file write D:\Temp\Test.txt" results in a filename like "D: Temp Test.txt". This should be checked.

This fix has also to be applied to repository WinFile.

GStegemann avatar May 29 '24 11:05 GStegemann

Thank you for the debugging. Will be fixed in the coming release 3.4.2, due next week.

edwig avatar May 30 '24 18:05 edwig

This one should be fixed by the latest check-in. Please retest at your leasure.

edwig avatar May 31 '24 17:05 edwig

Hello Edwig,

many thanks. I will test it next week.

Best regards, Gerhard

GStegemann avatar May 31 '24 19:05 GStegemann

Hello Edwig,

I triedy to test ":file" command fix. The test failed.

Installing Version 3.4.2 32 Bits installed an executable of ODBCQueryTool.exe dated 30.12.2023. I think this happens due to build errors.

I ran a batch build of all variants of OpenODBCQuery, which throws two times the following error:

Schweregrad	Code	Beschreibung	Projekt	Datei	Zeile	Unterdrückungszustand	Details
Fehler	RC1015	cannot open include file 'StyleFramework.rc'.	QueryTool	D:\sandbox\ODBCQueryTool\QueryTool\res\QueryTool.rc2	10		

And subsequently the build step Installer failed as well:

Schweregrad	Code	Beschreibung	Projekt	Datei	Zeile	Unterdrückungszustand	Details
Fehler	MSB3073	Der Befehl "cd "D:\sandbox\ODBCQueryTool\Installer\Installer_32Bits"
"D:\Program Files (x86)\NSIS\makensis.exe" Installer_32Bits.nsi

:VCEnd" wurde mit dem Code 1 beendet.	Installer	C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets	156		

Then I removed the statement "#include "StyleFramework.rc" from QueryTool.rc2 and build completed successfully. Is that the correct way to fix this?

GStegemann avatar Jun 03 '24 09:06 GStegemann

Removing the #include statement did not work.

The following changes do work:

  • changing the #include statement to "#include "..\..\StyleFramework\StyleFramework.rc""
  • copying all StyleFramework\res\ScrollBar?.bmp files to QueryTool\res.

After that builds do pass and OpenODBCQuery.exe does not crash anymore.

And yes, the ":file" command does work now as well.

GStegemann avatar Jun 03 '24 13:06 GStegemann