w1nk / node-odbc

unixODBC bindings for node
MIT License
90 stars 101 forks source link

Firebird, TimeStamp,Windows: Process finished with exit code 0xC0000005 #102

Open mtrezzi opened 8 years ago

mtrezzi commented 8 years ago

Hi,

I'm using node-odbc with firebird 2.5 and a dialect 3 database. Node.js crashes and the process finishes with exit code 0xC0000005 when my application executes a query containing timestamp fields .

Here is the code to create table and insert data:

CREATE TABLE TIMETEST (ID INTEGER PRIMARY KEY NOT NULL, TIMEFIELD TIMESTAMP);
COMMIT;
INSERT INTO TIMETEST (ID, TIMEFIELD) VALUES (2, '03-30-2016 12:00:00');
COMMIT;

Here is the node.js code:

var db = require('odbc')(),
    cn='DSN=MYDB;Uid=SYSDBA;Pwd=masterkey';

console.log('Opening');
db.open(cn, function (err) {
    console.log(err ? 'CONNECTION ERROR: ' + err : 'CONNECTED');

    var query =  'SELECT * FROM TIMETEST ';
    db.query(query, function (err, data) {
        console.log(err ? 'QUERY ERROR: ' + err : 'NO QUERY ERROR');
        console.log(data);
        console.log('Closing');
        db.close(function () {
            console.log('done');
        });
    });
});

I never get "closing" nor "done" log messages, but the system crashes during "db.query" execution.

Here is the WebStorm debugger console output:

Opening
CONNECTED

Process finished with exit code -1073741819 (0xC0000005)
wankdanker commented 8 years ago

Hi @mtrezzi! I'm not sure I can help you all the way through this, but you might try enabling debugging in the odbc module (https://github.com/wankdanker/node-odbc#debug). At least we can then see where it is getting internally before crashing.

mtrezzi commented 8 years ago

Hi @wankdanker! I enabled debugging in the odbc module. Now the program prints out continuously the following line:

ODBC::GetColumnValue - String: index=2 name=T type=93 len=38 value=2 ret=0 bufferLength=1048575

The column 2 is the TIMESTAMP Now the program remains stuck in a loop.

wankdanker commented 8 years ago

My best guess is that the Firebird TimeStamp types maps to some ODBC type other than SQL_DATETIME or SQL_TIMESTAMP. A quick look at /usr/include/sql.h indicates that SQL_TYPE_TIMESTAMP has the value 93 that is being reported in the debug output. I'd suggest trying to add a case for SQL_TYPE_TIMESTAMP at https://github.com/wankdanker/node-odbc/blob/master/src/odbc.cpp#L418, then recompile and try again.

mtrezzi commented 8 years ago

Thank you for your kind cooperation and your prompt reply. I will try it and I will let you know.

Massimiliano


Da: Dan VerWeire notifications@github.com Inviato: giovedì 14 aprile 2016 15.37 A: w1nk/node-odbc Cc: Massimiliano Trezzi Oggetto: Re: [w1nk/node-odbc] Firebird, TimeStamp,Windows: Process finished with exit code 0xC0000005 (#102)

My best guess is that the Firebird TimeStamp types maps to some ODBC type other than SQL_DATETIME or SQL_TIMESTAMP. A quick look at /usr/include/sql.h indicates that SQL_TYPE_TIMESTAMP has the value 93 that is being reported in the debug output. I'd suggest trying to add a case for SQL_TYPE_TIMESTAMP at https://github.com/wankdanker/node-odbc/blob/master/src/odbc.cpp#L418, then recompile and try again.

You are receiving this because you were mentioned. Reply to this email directly or view it on GitHubhttps://github.com/w1nk/node-odbc/issues/102#issuecomment-209945578

mtrezzi commented 8 years ago

Hi @wankdanker! Your solution that you suggest works. Thanks!