Skip to content
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

Windows ODBC driver hangs or crashes on simple queries #3381

Closed
monetdb-team opened this issue Nov 30, 2020 · 0 comments
Closed

Windows ODBC driver hangs or crashes on simple queries #3381

monetdb-team opened this issue Nov 30, 2020 · 0 comments

Comments

@monetdb-team
Copy link

@monetdb-team monetdb-team commented Nov 30, 2020

Date: 2013-10-03 15:17:56 +0200
From: Tim H. <<monetdb.bug.reporter>>
To: clients devs <>
Version: 11.15.15 (Feb2013-SP4)

Last updated: 2013-10-22 14:42:08 +0200

Comment 19239

Date: 2013-10-03 15:17:56 +0200
From: Tim H. <<monetdb.bug.reporter>>

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.76 Safari/537.36
Build Identifier:

This issue reproduces when using the ODBC driver from both node.js and python scripts to select * from sys.tables.

In a node.js script the query never finishes and the ODBC log files with 100s of MB of data after a few minutes. In a python script that uses the ODBC driver to perform the same query, it simply crashes.

Reproducible: Always

Steps to Reproduce:

(This example requires node.js)

Make a directory C:\temp\example

Change to this directory in a command prompt and run:
npm install odbc util

Create C:\temp\example\hang.js with the following contents
var odbc = require("odbc")
, util = require('util')
, db = new odbc.Database()
;
var connectionString = "DSN=monetdb;UID=monetdb;PWD=monetdb";
db.open(connectionString, function(err) {
db.query("select * from sys.tables;", function(err, rows, moreResultSets) {
console.log(util.inspect(rows, null, 10));
db.close(function() {
console.log("Database connection closed");
});
});
});

Now run: node hangs.js

Actual Results:

The call to the ODBC driver never returns and the program hangs.

Expected Results:

The results of the query should be printed to the console.

Log the ODBC details by creating a system environment variable:
ODBCDEBUG=c:\temp\example\odbc.log

When running the above example, this file will fill with 100s of MB of data if you let it run for 10 minutes or more.

Comment 19241

Date: 2013-10-04 10:30:13 +0200
From: @sjoerdmullender

I can reproduce the problem with your script.
But I'm not at all sure whether the problem is in the ODBC driver. The log that is produced contains (relevant bits extracted):

SQLExecDirectW 22f67630
SQLExecDirect: "select * from sys.tables;"
ODBCInitResult: querytype Q_TABLE, rowcount 32
SQLFetch 22f67630
SQLNumResultCols 22f67630
[getting values for column various attributes]
SQLGetData 22f67630 1 SQL_C_SLONG
SQLGetData 22f67630 2 SQL_C_WCHAR
SQLGetData 22f67630 2 SQL_C_WCHAR
[this last statement repeated over and over again]

I am able to run this inside the debugger and see exactly what's going on.

Luckily I can also see the code that node.js uses to retrieve the data. There I see that it calls SQLGetData multiple times because of this:
if ( == ret) {
//we have captured all of the data
break;
}
else if (SQL_SUCCEEDED(ret)) {
//we have not captured all of the data yet

where ret is the return value from SQLGetData. The MonetDB ODBC driver returns SQL_SUCCESS, which according to the documentation should be returned when all data was successfully transfered. It seems to me the bug is in the node.js ODBC library. It does not distinguish between SQL_SUCCESS (data complete) and SQL_SUCCESS_WITH_INFO (data transfered, but there is more).

Having ssid this, the MonetDB ODBC driver could be more robust here and return SQL_NO_DATA for the second call to SQLGetData.

I base my interpretation of the return valus on http://msdn.microsoft.com/en-us/library/ms715441%28v=vs.85%29.aspx section Retrieving Variable-Length Data in Parts.

Comment 19242

Date: 2013-10-04 14:22:36 +0200
From: MonetDB Mercurial Repository <>

Changeset 98edd5aa0196 made by Sjoerd Mullender sjoerd@acm.org in the MonetDB repo, refers to this bug.

For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=98edd5aa0196

Changeset description:

Implemented retrieving variable-length data in parts with SQLGetData.
This fixes bug #3381.

Comment 19243

Date: 2013-10-04 15:08:55 +0200
From: @sjoerdmullender

This will be in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant