You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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:
Comment 19243
Date: 2013-10-04 15:08:55 +0200
From: @sjoerdmullender
This will be in the next release.
The text was updated successfully, but these errors were encountered: