GithubHelp home page GithubHelp logo

node-firebird's People

Contributors

777777missu7777777 avatar ahasanempower avatar angeligareta avatar benthepoet avatar calvin avatar dependabot-preview[bot] avatar dependabot[bot] avatar dmitov avatar hgourvest avatar igorklopov avatar jesusvilla avatar jprando avatar mapopa avatar maratth avatar mariuspopaadrian avatar mariuz avatar michaelmcleodnz avatar monken avatar paulish avatar pcandido avatar petersirka avatar pomgui avatar rafatcb avatar sdnetwork avatar thekevinbrown avatar tomas2d avatar winstonewert avatar yumonra07 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-firebird's Issues

Error: invalid BLOB ID when selecting blob from stored procedure (in 0.3.0)

Node Firebird 0.3.0 throws : Error: invalid BLOB ID when selecting blob from stored procedure

Selecting blobs from a table works.
Selecting blobs form a stored procedure works in 0.1.4,

(using Firebird 2.5.2)

I have set-up a test branch on my new project, with tests on V0.3.0 and V0.1.4
https://github.com/quale-quest/sql-mvc/tree/fbdriver (feedback appreciated)

Basic test case:

var test_0_3_0_B = function () { //
    //in node firebird 0.3.0 throws :  Error: invalid BLOB ID  when selecting blob from stored procedure
    /*
    SET TERM ^ ;
    CREATE PROCEDURE SPTEST (
    INX VARCHAR(40)
    )
    RETURNS (
    INFO VARCHAR(1000),
    RES BLOB SUB_TYPE 1 )
    AS
    BEGIN
    info=INX;
    res=INX;
    suspend;
    END^
    SET TERM ; ^
     */

    Firebird.attach(load_config(), function (err, db) {

        if (err)
            throw err;

        db.query("SELECT a.info,a.RES FROM SPTEST ('12345') a;", function (err, result) {
        console.log("SELECT a.info,a.RES FROM SPTEST ('12345') a  : \n", err, result);

            //Error: invalid BLOB ID thrwon here >>>
            result[0].res(function (err, name, e) {
                if (err)
                    throw err;

                e.on('data', function (chunk) {
                    // reading data
                    console.log("receive chunk : \n", chunk.length, chunk);
                });

                e.on('end', function () {
                    // end reading
                    // IMPORTANT: close the connection
                    console.log("receive end : \n");
                    db.detach();
                });
            });

            db.detach();
        });

    });

    return;
};

SELECT of NUMERIC(15,2) field returns undefined

I just upgraded to v0.2.3 and there seems to be a regression issue.

I have (eg): select FEE from SOME_TABLE. The FEE field is Numeric(15,2). Node-firebird is returning 'undefined'. It all works from IBExpert.
BTW, same issue occurs whether it is a straight table query or selectable stored procedure.

Cheers. Eric.

Execution hangs after connection

Hello, I have a program like this:

var sys = require('util'),
    fb = require("node-firebird");
//-----------------------------------------------------------------------------
console.log('start');
fb.attach('127.0.0.1', 3050, '/baze/node.fdb', 'SYSDBA', '*****',
    function(database){
        db = database;
        console.log("connected");
    },
    function(error){
        console.log("can't connect");
    }
);
console.log('Running...');

It prints:

start
Running...
connected

and just sits there. The program does not end, I need to kill it with ctrl+c.

Is this normal behavior?

how to get column owner table ?

hi;

how to get column owner table in statement.output ? because this query "select * from table1 t1 left outer join table2 t2 on t2.t1_id = t1.id" include same column name (id) and same alias value in statement.output. i want a generate "insertsql, updatesql and deletesql" and this a big problem for me.

thanks.

Changes between 0.1.x 0.2.x and 0.3.x Transactions broken?

Hello,
I 'm using version 0.1.1 under node 0.8.10 in production since a long time ago. Everything runs fine.
So i tried to upgrade to version 0.2.

Under 0.2.x, a query that should raise an error (because of violation of relations) , raise no error . (I tried all 0.2.x Versions). For example: delete from table a where table.a.primkey = ?. (Under the assumption there exists table b with a reference to table a).

If it is not a "relation error" -> say for example: "arithmetic overflow" then the error ist handled correctly.
So i think the following:
case 1: the error is identified before transaction.commit -> everything is ok
case 2: the error is deteced in the transaction.commit block -> it fails.

So what I'm doing wrong? Is there a critical api change between version 0.1.x and 0.2.x?
My transactions are basically like this:

function do_something(transaction,sqlString,sqlParameter,callback) {
/* transaction isolation_level = read_commited /
transaction.execute(sqlString, sqlParameter, function(err, result, meta) {
if(err) {
/
on version 0.1.1 this will executed /
tr.rollback();
return(callback(err);
} else {
/
on version 0.2.x this will executed /
result = do_something_on_result_and_meta(result,meta); /
in version 0.2.x meta = null */
tr.commit(function(err) {
return(callback(err));
}
}
}

Date field Type error: value is out of bounds

hi;

I get an error when assigning the value date field. I did the assignment date format "dd.mm.yyyy". I change the date format like "yyyy-mm-dd". not error. Windows 8 system regional settings, date format "dd.mm.yyyy".

the origin of the problem?

thanks.

error:

TypeError: value is out of bounds TypeError: value is out of bounds
    at TypeError (<anonymous>)
    at checkInt (buffer.js:784:11)
    at Buffer.writeInt32BE (buffer.js:924:5)
    at XdrWriter.addInt (D:\VetaDepo\Veta Nuo\VW_JS\node_modules\node-firebird\l
ib\serialize.js:192:17)
    at SQLParamDate.encode (D:\VetaDepo\Veta Nuo\VW_JS\node_modules\node-firebir
d\lib\index.js:830:14)
    at D:\VetaDepo\Veta Nuo\VW_JS\node_modules\node-firebird\lib\index.js:1888:2
9
    at done (D:\VetaDepo\Veta Nuo\VW_JS\node_modules\node-firebird\lib\index.js:
1737:17)
    at PrepareParams (D:\VetaDepo\Veta Nuo\VW_JS\node_modules\node-firebird\lib\
index.js:1851:25)
    at Connection.executeStatement (D:\VetaDepo\Veta Nuo\VW_JS\node_modules\node
-firebird\lib\index.js:1870:9)
    at Statement.execute (D:\VetaDepo\Veta Nuo\VW_JS\node_modules\node-firebird\
lib\index.js:915:21)

Callback passed to 'database.query' in some situations is called twice

Hi!

I'm facing a problem using node-firebird client. To test performance of my Node.js server I wrote a special load test which send specific request to my server.
This request is responsible for sending simple update query to Firebird database using node-firebird client. It is important to mention, that I use NO WAIT transaction for this queries.
As a result, for some requests I got a Firebird error (which isn't strange at all):

{ 
  handle: 3, 
  status: 
  [ { gdscode: 335544345 }, 
    { gdscode: 335544336 }, 
    { gdscode: 335544451 }, 
    { gdscode: 335544878, params: [Object] } ], 
  message: 'lock conflict on no wait transaction, deadlock, update conflicts with concurrent update, concurrent transaction number is 350831'
}

Unfortunately, in some situations I got an error from Express web application framework:

http.js:689 
    throw new Error('Can\'t set headers after they are sent.'); 
          ^ 
Error: Can't set headers after they are sent. 
    at ServerResponse.OutgoingMessage.setHeader (http.js:689:11) 
    at ServerResponse.res.set.res.header (XXX\node_modules\express\lib\response.js:550:10) 
    at ServerResponse.res.send (XXX\node_modules\express\lib\response.js:131:12) 
    at ServerResponse.res.jsonp (XXX\node_modules\express\lib\response.js:267:15) 
    at ... <source-file-written-by-me> ...
    at XXX\node_modules\node-firebird\lib\index.js:1081:37 
    at doCallback (XXX\node_modules\node-firebird\lib\index.js:870:13) 
    at XXX\node_modules\node-firebird\lib\index.js:1251:25 
    at XXX\node_modules\node-firebird\lib\messages.js:136:37

I tried to investigate this problem and it seems that in some situations (under quite heavy load), when a query to Firebird fails to execute and generates an error, a callback parameter passed to database.query method is called twice. As a result, Express also tries to send response for a request twice which is of course impossible, because response has already been sent.
Could you please check if it is possible, that this callback is called twice?
I tried to analyze implementation of methods: Database.execute, doCallback, Connection, messages.lookupMessages (according to line numbers specified in exception stack trace), but I think your assistance in this matter would be greatly appreciated.
I have managed to log stack trace for these 2 locations, at which I think callback was executed:
1)

    at ... <source-file-written-by-me> ...
    at XXX\node_modules\node-firebird\lib\index.js:1081:37 
    at doCallback (XXX\node_modules\node-firebird\lib\index.js:870:13) 
    at Socket.<anonymous> (XXX\node_modules\node-firebird\lib\index.js:1255:17) 
    at Socket.emit (events.js:95:17) 
    at Socket.<anonymous> (_stream_readable.js:748:14) 
    at Socket.emit (events.js:92:17) 
    at emitReadable_ (_stream_readable.js:410:10) 
    at emitReadable (_stream_readable.js:406:5) 
    at ... <source-file-written-by-me> ...
    at XXX\node_modules\node-firebird\lib\index.js:1081:37 
    at doCallback (XXX\node_modules\node-firebird\lib\index.js:870:13) 
    at XXX\node_modules\node-firebird\lib\index.js:1251:25 
    at XXX\node_modules\node-firebird\lib\messages.js:136:37 
    at search (XXX\node_modules\node-firebird\lib\messages.js:103:13) 
    at XXX\node_modules\node-firebird\lib\messages.js:49:25 
    at Object.wrapper [as oncomplete] (fs.js:459:17)

The problem seems to be strictly connected to lines 1247 - 1256 of index.js file of node-firebird client:

    if (obj && obj.status) {
        messages.lookupMessages(obj.status,
            function(message){
                obj.message = message;
                doCallback(obj, cb);
            }
        )
    } else {
        doCallback(obj, cb);
    }

Thank you in advance for any help you can provide!

cannot insert/update

Hello,

if i try to insert a record, for example:

conn.execute("insert into code_gema_land (land,wert) values(?,?)",['DE',3]

I get the following error:

/home/michael/node_modules/node-firebird/lib/index.js:965
callback(ret)
^
ReferenceError: ret is not defined
at /home/michael/node_modules/node-firebird/lib/index.js:965:38
at doCallback (/home/michael/node_modules/node-firebird/lib/index.js:870:9)
at Socket. (/home/michael/node_modules/node-firebird/lib/index.js:1124:13)
at Socket.emit (events.js:67:17)
at TCP.onread (net.js:341:14)

It seems, only select statements are possible , what are I'm doing wrong? (The insert statement ist ok - i checked it with isql)

2 separate pools cause issue.

I have 2 main parts to my application so I want to create 2 separate pools. If I give the 1st pool 5 connections then I can only give the 2nd pool maximum 3 connections or it will die with the following message:

Lender V3DATA connections: 5
Product V3DATA connections: 4
Express server listening on port 3000
V3DATA connected (Settings)...
V3DATA connected (Download)...
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Database.addListener (events.js:160:15)
at Connection.attach (/home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:1781:21)
at /home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:1248:21
at doCallback (/home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:915:5)
at Socket. (/home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:1536:17)
at Socket.emit (events.js:95:17)
at Socket. (stream_readable.js:764:14)
at Socket.emit (events.js:92:17)
at emitReadable
(_stream_readable.js:426:10)
at emitReadable (_stream_readable.js:422:5)

I'm using the latest node-firebird release. Cheers.

Database.Query, Database.Execute does not work on AppJS

Hi,

I'm trying to create a desktop application using AppJS & Node-firebird but nothing happens when I try to fetch data for the database, the only thing I get is "Connected to Zino" on the console when I connect, it seems that the callback function is not called.

Here is my code

fb = require("node-firebird");

fb.attach(
    {
        host: '127.0.0.1',
        database: 'C:/Work Station/Zino/data/app/ZINO.FDB',
        user: 'SYSDBA',
        password: 'masterkey'
    },
    function(err, db){
        if (err) {
            console.log(err.message);
        } else {
            database = db;
            console.log("Connected to Zino");
        }
    }
);

database.query("select * from users",
    function (err, result) {
        console.log(result);
    }
);

I really appreciate your help, thank you.

error when running test5 on windows 7 64bit (FB2.1.4) - any ideas Henri

C:\bin\node_modules\node-firebird\lib\serialize.js:142
var len = this.buffer.readUInt16LE(this.pos);
^
TypeError: Cannot call method 'readUInt16LE' of undefined
at BlrReader.readSegment (C:\bin\node_modules\node-firebird\lib\serialize.js
:142:27)
at C:\bin\node_modules\node-firebird\lib\index.js:1932:56
at doCallback (C:\bin\node_modules\node-firebird\lib\index.js:881:13)
at Socket. (C:\bin\node_modules\node-firebird\lib\index.js:1266:1
7)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket. (stream_readable.js:710:14)
at Socket.EventEmitter.emit (events.js:92:17)
at emitReadable
(_stream_readable.js:382:10)
at emitReadable (_stream_readable.js:378:5)
at readableAddChunk (_stream_readable.js:143:7)

Is it possible to read blobs? (FB2.1 character set none)

node_moduib\serialize.js:142
var len = this.buffer.readUInt16LE(this.pos);
^
TypeError: Cannot call method 'readUInt16LE' of undefined

*** Additional Notes:

  1. It seems to work but doesn't handle empty strings or NULL gracefully.
  2. Need to use transactions to retrieve blobs (or so it seems)
  3. The utility function ab2str() is useless with blobs - how to convert to a string then?
  4. Crashed the FB server on my local machine...

function ab2str(buf) {
return String.fromCharCode.apply(null, new Uint16Array(buf));
}

How do I get the results?

If I run a select query my results look like this:

[ Buffer 4d 6f 6c 64 6f 76 61 ],
[ Buffer 4d 6f 6e 61 63 6f ],
etc...

This is my code:

var fb = require("node-firebird");
db = "myDB";

fb.attach("127.0.0.1", 3050, db, "SYSDBA", "masterkey",
function(db) {
database = db;
console.log("connected");
database.execute("select * from COUNTRIES order by COUNTRY;",
function (result) {
console.log(result.data);
}
);
},
function(error) {
console.log("can't connect");
}
);

Am I doing something wrong or is this a bug?
I'm using Windows XP.

Thanks.

Firebird 1.5

Hi
I'm trying to run node-firebird with Firebird 1.5 without success.
It connects ok but execute doesnt trigger any action, no error, silently ignores callback.
The same code works fine with Firebird 2.5
Platform Windows 7
Due to compatibility issues I can't upgrade database server so any solution will be appreciate.
Paul

running query in async

Hello,
I've a real time app that receives data (via network) from sensors and need to insert it into firebird db.
I'm creating connection to db via attach method and then run queries like this:

//insert into table
var sql_txt1 = "EXECUTE PROCEDURE INSERT_POS(" +....;
dbcon.query(sql_txt1, null, function(err, result){
if (err) console.log("error in insert_pos:" + err + ":" + sql_txt1);
});

//update
var sql_txt2 = "EXECUTE PROCEDURE UPDATE_COUNT(" +....;
dbcon.query(sql_txt2, null, function(err, result){
if (err) console.log("error in update_count:" + err + ":" + sql_txt2);
});

In the begining, things go fine, but when a big number of sensors start sending data, I receive (sometimes) messages telling that no transaction handle and that the transaction must be started explicit, which leads to data loss which may be critical in some situations.

I guess the problem comes from query being executed when previous query wasn't commited yet. Does the module automatically starts a new transaction with each new query or should I start them manually and how?

thank you

role

Is there a way to specify a role during database connection?

Closing Sockets, invalid clumplet buffer structure

Hi there!

First of all I would like to thank you for a great product! You did an awesome job!

I am having a little trouble thou.
First I am creating one connection to db - then I start quering it several times every 3 seconds, and everythig is well, but in time there is trouble - the Node can Say that "This socket is closed", so next time I try to query - node crashes.
And sometimes db responses with "invalid clumplet buffer structure: string length doesn't match with clumplet" and then also crash.

I have one connection and several seelct queries. Do I need to create a connection for each of them?

Thank you in advance.

Problems with fetching

Simple test gives me strange result

var cfg = require("./config").cfg;
var fb = require('./node-firebird/lib/index.js');

var con =  new fb.Database('127.0.0.1', 3050, cfg.db, cfg.user, cfg.password,function(){
    con.execute("select * from rdb$relations", function(rs){
         console.log(rs.data.length);

         con.execute("select count(*) from rdb$relations", function(rs){
            console.log(rs.data[0][0]);
         });
    });    

});

produces strange result

node st.js
59
47

Fast reconnection.

Hi there, it's me again with another question. If I cannot avoid the problem I am guessing I can try to restore it.
So if at some point the connection with database was lost, how can I restore it?

Thank you in advance!

node-firebird sync

hi;

this library is async and i need to use sync this library. this possible ?

best regards.

Question(s)

Backgroundinformation: I work on a project using nod-firebird-libfbclient. Now I want to test node-firebird also, because you are offering multiple transactions in the same connection, wich is really nice.

Question 1:
In node-firebird-libfbclient i can get the result rows as Objects e.g [{ land: "DE"} ]
is this also possible.

Question 2:
Wen i execute a query say database.execute("select land from code_gema_land");
I get an object containing the Metainformation (where i can get the columnames) and the Data (resulting rows).

When i use a statement object say
statement.execute .... and then fetch the records with statement.fetch...
I didn't get the metainformation. Is there a way to get the metainfo in this case also?

Question 3:

When i use database.execute I get all rows in one "shoot" .
This means, the complete resulting set is sent - correct? - or will this be temporarily constructed one by one when i loop over it?

Thanks in advance
Michael

The example program does not exit

When I run the example from the README.md, the program does not exit. Is this known and I missed something?

Will provide more information when asked, but as this project looks a bit stale, I won't bother as long as I don't know whether anyone will look at this issue.

Bigger 23 fields query problem

Hi;

We test a node-firebird library but have a problem.

Example; "Select * From People" query include 65 fields in result. This query except error "length" undefined. But "Select * From Human" query include 20 fields in result all is ok. So fields count bigger 23 than node-firebird library get error.

Best regards.

Date and time zone

var con =  new fb.Database('127.0.0.1', 3050, cfg.db, cfg.user, cfg.password,function(){
    con.execute("select Date 'today' from rdb$database", function(rs){
         console.log(rs.data.length);
         console.log(rs.data[0][0]);
    });    
});

outputs

[xdenser@localhost node-firebird]# node date-issue.js
1
Sat, 09 Jun 2012 00:00:00 GMT

while

[xdenser@localhost node-firebird]# date -u
Fri Jun  8 22:23:17 UTC 2012

Same applies to timestamp and time fields.

json result set

Hi,
I've almost completed a conversion of a mysql nodejs server to firebird sql 2.5 and have the following issue with the json result set. The mysql lib delivers the json payload with the expected json notation while firebird lib seems to separate the metadata and the data. While I can see the potential benefits of the separation, I need all my result sets to have the embedded metadata and would like to know if there is a simple solution. When I've completed the conversion I will publish and blog for the firebird community. In summary, if my select brings back 2 records, I'm hoping for the json result to look like:

[{"id":2000,"Time":"Wed 9-19","User":"ADRIAN","event":"IOI B 100,000","symbol":"AA
PL","Targets":[{"Target":"CHUBB","Reason":"AF"},{"Target":"TIGER","Reason","I"}]},
{"id":2001,"Time":"Wed 9-20","User":"ADRIAN","event":"IOI B 10,000","symbol":"GOGL","Targets":[{"Target":"ABCO","Reason":"AF"},{"Target":"TIGER","Reason","H"}]}]

Thanks,
John

Exact metadata copy of the database exists for both mysql and firebird. The example uses the following query with slight mods for each database:

SELECT "idevents" "id", "evtUser" "User", "evtText" "event", "evtSymbol" "symbol", "evtTarget" "Targets" FROM "events" WHERE "idevents" > 0 AND "evtUser"
= 'ADRIAN' ORDER BY "idevents" DESC

Stack:
Nodejs, expressjs, node-firebird, socketio, jade, angularjs

mysql

debug - websocket writing 5:::{"name":"init","args":[{"Alerts":[{"id":2000,"T
ime":"Wed 9-19","User":"ADRIAN","event":"IOI B 100,000 AAPL 489.73","symbol":"AA
PL","Targets":[{"Target":"CHUBB","Reason":"AF"},{"Target":"TIGER","Reason":"H"}]
},{"id":1999,"Time":"Wed 9-19","User":"ADRIAN","event":"NWS AAPL Streetinsider.c
om's Hot Lunchtime Reads 09/17: (CVX) (MPEL) (X) (AAPL) (QCOR)","symbol":"AAPL",
"Targets":[{"Target":"CHUBB","Reason":"AF"},{"Target":"TIGER","Reason":"H"}]}]}]
}

firebird

c:\users\jdittemer>cd C:\Node\Apps\Pecrm

C:\Node\Apps\Pecrm>node testExp2.js

data { meta:
[ { type: 496,
nullable: false,
subType: 0,
scale: 0,
length: 4,
field: 'idevents',
relation: 'events',
alias: 'id' },
{ type: 448,
nullable: true,
subType: 4,
scale: 0,
length: 200,
field: 'evtUser',
relation: 'events',
alias: 'User' },
{ type: 448,
nullable: true,
subType: 4,
scale: 0,
length: 2000,
field: 'evtText',
relation: 'events',
alias: 'event' },
{ type: 448,
nullable: true,
subType: 4,
scale: 0,
length: 400,
field: 'evtSymbol',
relation: 'events',
alias: 'symbol' },
{ type: 520,
nullable: true,
subType: 1,
scale: 4,
length: 8,
field: 'evtTarget',
relation: 'events',
alias: 'Targets' } ],
data:
[ [ 1,
'ADRIAN',
'NWS FDX Trading Radar for 09/18: FedEx (FDX), Man U (MANU), Schiff Nutri
tion (SHF) Report',
'IBM',
'[{"Target":"DENALI","Reason":"I"}]' ] ] }
Done mycallback3, about to do socket.emit ! 0 1
debug - websocket writing 5:::{"name":"init","args":[{"Alerts":[[1,"ADRIAN","
NWS FDX Trading Radar for 09/18: FedEx (FDX), Man U (MANU), Schiff Nutrition (SH
F) Report","IBM","[{"Target":"DENALI","Reason":"I"}]"]]}]}

retrieving BIGINTfrom db is faulty

Hello,
I've a table with a BIGINT field, I'm running a simple select query.
The values being retrieved are different from those stored in db. They are only ok with field values being small, but with real big int values like 862304020112911, the values being retrived are negative values and thus wrong.

As a workaround, I'm casting to varchar(20) and later parseInt() the result.

Regards

Fieldvalues Textfields with len 0 etc.

Hello,

  1. When i select from a char/varchar field with an empty value '' (not null) then i get as value "undefined".
    Is this a bug or the desired behaviour?

  2. When i create a view with a case construct say:

case f.rdb$field.type

when 261 then 'BLOB'
when 14 then 'CHAR'
when 40 then 'CSTRING'
....

then i get a "buffer" (i don't know what object this is) return

if i change this to:

case f.rdb$field_type
when 261 then cast('BLOB' as varchar(10))
when 14 then 'CHAR'
when 40 then 'CSTRING'
....

then i get a normal string

  1. When i select a field with datatype BIGINT (int64) then i get an object with
    {high: 0, low: 395}
    Why is this not a javascript int?

Passing multiple params to query doesnt work

There is some bug causing this block to work inproperly (lines 1847 - 1853):

if (!(params instanceof Array)) {
        if (params !== undefined) {
            params = [params];
        } else {
            params = [];
        }
    }

I'm using this code trying to get results from query:

var dbparams = new Array(0);
dbparams[0] = 7;
dbparams[1] = 13;

        database.query("select klienci_opis from klienci where klienci_id > 0", dbparams,
            function (err, result) { 

[ . . .]

I get following error:

Uncaught node.js Error

Error: expected parametters: 2
at Connection.executeStatement (D:\Dropbox\source_examples\node-js\node_modules\node-firebird\lib\index.js:1855:19)
at Statement.execute (D:\Dropbox\source_examples\node-js\node_modules\node-firebird\lib\index.js:902:21)
at D:\Dropbox\source_examples\node-js\node_modules\node-firebird\lib\index.js:949:23
at D:\Dropbox\source_examples\node-js\node_modules\node-firebird\lib\index.js:1690:17
at doCallback (D:\Dropbox\source_examples\node-js\node_modules\node-firebird\lib\index.js:868:13)
at Socket. (D:\Dropbox\source_examples\node-js\node_modules\node-firebird\lib\index.js:1253:17)
at Socket.EventEmitter.emit (events.js:104:17)
at readableAddChunk (_stream_readable.js:156:16)
at Socket.Readable.push (_stream_readable.js:123:10)
at TCP.onread (net.js:520:20)

I found that all this mess is because one condition doesnt work (line 1847):

if (!(params instanceof Array)) {

My params are array (I used in my code same condition to check it), I dont know why it doesnt work in your code. For now i fixed it temporarily changing line 1849 from:

params = [params];

to:

params = params;

It forces me to always use array even for single params, can you check it?

Firebird 3 test issues

If i run the tests with firebird 2.5 everything works as it should

node run.js
TEST ---> test_create: 720ms
TEST ---> test_reconnect: 42ms
TEST ---> test_insert: 358ms
TEST ---> test_select_insert: 100ms
TEST ---> test_update: 258ms
TEST ---> test_select_update: 52ms
TEST ---> test_transaction: 90ms
TEST ---> test_pooling: 2503ms

then if i switch to firebird 3.0 with firebird.conf

AuthServer = Legacy_Auth
WireCrypt= Disabled

assert.js:93
throw new assert.AssertionError({
^
AssertionError: TEST ---> test_insert: insert blob (stream) Error: Dynamic SQL Error, SQL error code = -804, SQLDA missing or incorrect version, or incorrect number/type of variables
at /home/mariuz/work/node-firebird/test/run.js:114:20
at doError (/home/mariuz/work/node-firebird/lib/index.js:1005:9)
at /home/mariuz/work/node-firebird/lib/index.js:1280:21
at doCallback (/home/mariuz/work/node-firebird/lib/index.js:999:5)
at Socket. (/home/mariuz/work/node-firebird/lib/index.js:1592:17)
at Socket.emit (events.js:95:17)
at Socket. (stream_readable.js:765:14)
at Socket.emit (events.js:92:17)
at emitReadable
(_stream_readable.js:427:10)
at emitReadable (_stream_readable.js:423:5)

Connection method signature...

Would suggest using .attach(... function(err,db){}) instead of the separated .attach(... function(db){}, function(err){}) in order to match conventions that most Node.js projects use. In fact, I would really suggest the following...

.attach(opts, function(err,db){})

Passing in an options object that contains either the local db path, or login credentials.

Username missing in batch job

Linux Issue:

If i start node as a damon at system boot time then there is no
process.env['USER'] and the connection fails at line 1247 in index.js

I can get around this if i say
export USER='somename' before i start the batch script,

.execute(execute procedure xxx) does not return proper error structure

I just tried to test my error handling with the following code:

this.copyProd = function(req, cb) {
 ppool.get(function(err, db) {
   if (err) {
     console.log("Ppool connection error: "+err);
     cb(err, null);
     return;
   }
   db.execute("execute procedure SP_COPYPRODUCT(?,?) reere", [req.params.pkey, req.session.ukey], 
     function (err, result) {
       db.detach();
       if (err) { console.log(err.message); cb(err,0); } else cb(err, result[0]);
   });  
 });  
};

The 'reere' string will generate a -104 exception ("Dynamic SQL Error, SQL error code = -104, Token unknown - line 1, column 39, reere"). The error message is in error.message as usual, but other error structure fields are not set, such as error.sqlcode.

Cheers. Eric.

Query problem with field type CHAR

After upgrading to [email protected] (or @0.3.0) queries with field type CHAR does not work any more. After the query method they never call the query callback function. If I downgrade to [email protected] it works.

This problem seems to occure when the result set has a field with type CHAR (not VARCHAR, but CHAR). I can reproduce the problem with this example table:

  • create a new table and insert a row :
    create table testtable ( field1 int, field2 varchar(80), field3 char(80), field4 char(1), field5 varchar(1)); 
    insert into testtable values (1, ’Test1’, ’Test1’, ’T’, ’T’);
  • do a node-firebird program with query ”select field1, field2, field3, field4, field5 from testtable”. The program hangs after executing the db.query-method.

  • change the query by removing field3 and field4 (char-typed fields) and run the program. It works fine.

    The problem seems to come from the commit d0cbb6b to lib/index.js:row 593 on 2014-11-14 changing the way string fields are read from the socket. When changing the lines from this commit back to 0.2.5 it works again. I noticed also that the version 0.2.5 returned four characters long fixed string for a char(1) so the result length was not correct in the old version.

    I’m using Node version 0.10.33 and Firebird version 2.5.3. The database character set is win1252 but it seemed to work similarly with utf-8. Please ask if you need any additional information about the problem or my environment.

    Thanks for a great node module! :-)

Heroku Node-Firebird , Help Please !!!

Hi i am new to Node , i try to deploy my app in heroku but a got this error related to firebird module .
PD : I love this module module

Log

-----> Node.js app detected
-----> Requested node range: 0.10.x
-----> Resolved node version: 0.10.33
-----> Downloading and installing node
-----> Exporting config vars to environment
-----> Installing dependencies
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data

   > [email protected] install /tmp/build_525edc25a2d8011b4a9bac0dd8c39611/node_modules/firebird
   > node-gyp rebuild

   make: Entering directory `/tmp/build_525edc25a2d8011b4a9bac0dd8c39611/node_modules/firebird/build'
     CXX(target) Release/obj.target/binding/src/fb-bindings.o
     CXX(target) Release/obj.target/binding/src/fb-bindings-blob.o
   ../src/fb-bindings-blob.cc: In static member function ???static v8::Handle<v8::Value> FBblob::WriteSync(const v8::Arguments&)???:
   ../src/fb-bindings-blob.cc:270:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
          if(alen < len) len = alen;
                    ^
   ../src/fb-bindings-blob.cc: In static member function ???static v8::Handle<v8::Value> FBblob::Write(const v8::Arguments&)???:
   ../src/fb-bindings-blob.cc:350:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
          if(alen < len) len = alen;
                    ^
   ../src/fb-bindings-blob.cc: In constructor ???FBblob::FBblob(ISC_QUAD*, Connection*, ISC_STATUS*)???:
   ../src/fb-bindings-blob.cc:397:17: warning: converting to non-pointer type ???isc_blob_handle {aka unsigned int}??? from NULL [-Wconversion-null]
        else handle = NULL;
                    ^
     CXX(target) Release/obj.target/binding/src/fb-bindings-fbresult.o
   ../src/fb-bindings-fbresult.cc: In static member function ???static v8::Handle<v8::Value> FBResult::set_params(XSQLDA*, const v8::Arguments&)???:
   ../src/fb-bindings-fbresult.cc:205:12: warning: unused variable ???date_num??? [-Wunused-variable]
        double date_num;
               ^
   ../src/fb-bindings-fbresult.cc: In static member function ???static v8::Local<v8::Value> FBResult::GetFieldValue(XSQLVAR*, Connection*)???:
   ../src/fb-bindings-fbresult.cc:402:10: warning: variable ???field_width??? set but not used [-Wunused-but-set-variable]
      short  field_width;
             ^
   ../src/fb-bindings-fbresult.cc:350:17: warning: unused variable ???len??? [-Wunused-variable]
        short       len; 
                    ^
   ../src/fb-bindings-fbresult.cc:353:17: warning: unused variable ???rawtime??? [-Wunused-variable]
        time_t      rawtime;
                    ^
   ../src/fb-bindings-fbresult.cc:354:17: warning: unused variable ???time_val??? [-Wunused-variable]
        double      time_val;
                    ^
   ../src/fb-bindings-fbresult.cc:355:14: warning: unused variable ???days??? [-Wunused-variable]
        int      days;
                 ^
   ../src/fb-bindings-fbresult.cc: In static member function ???static v8::Handle<v8::Value> FBResult::FetchSync(const v8::Arguments&)???:
   ../src/fb-bindings-fbresult.cc:596:15: warning: unused variable ???i??? [-Wunused-variable]
        short     i, num_cols; 
                  ^
   ../src/fb-bindings-fbresult.cc:596:18: warning: variable ???num_cols??? set but not used [-Wunused-but-set-variable]
        short     i, num_cols; 
                     ^
   ../src/fb-bindings-fbresult.cc: In static member function ???static void FBResult::EIO_After_Fetch(uv_work_t*)???:
   ../src/fb-bindings-fbresult.cc:678:11: warning: unused variable ???i??? [-Wunused-variable]
        short i, num_cols;
              ^
   ../src/fb-bindings-fbresult.cc:678:14: warning: variable ???num_cols??? set but not used [-Wunused-but-set-variable]
        short i, num_cols;
                 ^
   ../src/fb-bindings-fbresult.cc: In destructor ???virtual FBResult::~FBResult()???:
   ../src/fb-bindings-fbresult.cc:878:131: warning: format ???%d??? expects argument of type ???int???, but argument 3 has type ???ISC_STATUS {aka long int}??? [-Wformat=]
            printf("Error in free statement %s, %d, %d\n",ErrorMessage(status,err_message,sizeof(this->err_message)),status[1],SQLCODE);
                                                                                                                                      ^
   ../src/fb-bindings-fbresult.cc:878:131: warning: format ???%d??? expects argument of type ???int???, but argument 4 has type ???long int??? [-Wformat=]
   ../src/fb-bindings-fbresult.cc:883:15: warning: converting to non-pointer type ???isc_stmt_handle {aka unsigned int}??? from NULL [-Wconversion-null]
        else stmt = NULL;
                  ^
   ../src/fb-bindings-fbresult.cc: In static member function ???static v8::Local<v8::Value> FBResult::GetFieldValue(XSQLVAR*, Connection*)???:
   ../src/fb-bindings-fbresult.cc:437:40: warning: ???value??? may be used uninitialized in this function [-Wmaybe-uninitialized]
            js_field = Integer::New( value);
                                           ^
     CXX(target) Release/obj.target/binding/src/fb-bindings-connection.o
   ../src/fb-bindings-connection.cc: In member function ???bool Connection::Connect(const char*, const char*, const char*, const char*)???:
   ../src/fb-bindings-connection.cc:53:21: warning: deprecated conversion from string constant to ???char*??? [-Wwrite-strings]
        char *lc_type = "UTF8";
                        ^
   ../src/fb-bindings-connection.cc: In member function ???bool Connection::Close()???:
   ../src/fb-bindings-connection.cc:100:10: warning: converting to non-pointer type ???isc_db_handle {aka unsigned int}??? from NULL [-Wconversion-null]
          db = NULL;
             ^
   ../src/fb-bindings-connection.cc:103:8: warning: converting to non-pointer type ???isc_db_handle {aka unsigned int}??? from NULL [-Wconversion-null]
        db = NULL;
           ^
   ../src/fb-bindings-connection.cc: In member function ???bool Connection::process_statement(XSQLDA**, char*, isc_stmt_handle*, int*)???:
   ../src/fb-bindings-connection.cc:111:23: warning: unused variable ???var??? [-Wunused-variable]
         XSQLVAR         *var;
                          ^
   ../src/fb-bindings-connection.cc:114:35: warning: unused variable ???i??? [-Wunused-variable]
         short           l, num_cols, i, length, alignment, type, offset;
                                      ^
   ../src/fb-bindings-connection.cc:114:38: warning: unused variable ???length??? [-Wunused-variable]
         short           l, num_cols, i, length, alignment, type, offset;
                                         ^
   ../src/fb-bindings-connection.cc:114:46: warning: unused variable ???alignment??? [-Wunused-variable]
         short           l, num_cols, i, length, alignment, type, offset;
                                                 ^
   ../src/fb-bindings-connection.cc:114:57: warning: unused variable ???type??? [-Wunused-variable]
         short           l, num_cols, i, length, alignment, type, offset;
                                                            ^
   ../src/fb-bindings-connection.cc:114:63: warning: unused variable ???offset??? [-Wunused-variable]
         short           l, num_cols, i, length, alignment, type, offset;
                                                                  ^
   ../src/fb-bindings-connection.cc: In static member function ???static v8::Handle<v8::Value> Connection::QuerySync(const v8::Arguments&)???:
   ../src/fb-bindings-connection.cc:776:28: warning: converting to non-pointer type ???isc_stmt_handle {aka unsigned int}??? from NULL [-Wconversion-null]
        isc_stmt_handle stmt = NULL;
                               ^
   ../src/fb-bindings-connection.cc: In static member function ???static v8::Handle<v8::Value> Connection::PrepareSync(const v8::Arguments&)???:
   ../src/fb-bindings-connection.cc:963:28: warning: converting to non-pointer type ???isc_stmt_handle {aka unsigned int}??? from NULL [-Wconversion-null]
        isc_stmt_handle stmt = NULL;
                               ^
   ../src/fb-bindings-connection.cc: In constructor ???Connection::Connection()???:
   ../src/fb-bindings-connection.cc:1000:8: warning: converting to non-pointer type ???isc_db_handle {aka unsigned int}??? from NULL [-Wconversion-null]
        db = NULL;
           ^
   ../src/fb-bindings-connection.cc:1001:11: warning: converting to non-pointer type ???isc_tr_handle {aka unsigned int}??? from NULL [-Wconversion-null]
        trans = NULL;
              ^
   ../src/fb-bindings-connection.cc: In destructor ???virtual Connection::~Connection()???:
   ../src/fb-bindings-connection.cc:1009:9: warning: NULL used in arithmetic [-Wpointer-arith]
     if(db!=NULL) Close();
            ^
   ../src/fb-bindings-connection.cc:1010:5: warning: NULL used in arithmetic [-Wpointer-arith]
        assert(db == NULL);
        ^
     CXX(target) Release/obj.target/binding/src/fb-bindings-eventblock.o
   ../src/fb-bindings-eventblock.cc: In member function ???void event_block::removeEvent(char*)???:
   ../src/fb-bindings-eventblock.cc:288:35: warning: operation on ???buf??? may be undefined [-Wsequence-point]
            buf = buf + (*(buf++)) + 4;
                                      ^
     CXX(target) Release/obj.target/binding/src/fb-bindings-fbeventemitter.o
     CXX(target) Release/obj.target/binding/src/fb-bindings-statement.o
     SOLINK_MODULE(target) Release/obj.target/binding.node
   /usr/bin/ld: cannot find -lfbclient
   collect2: error: ld returned 1 exit status
   make: *** [Release/obj.target/binding.node] Error 1
   make: Leaving directory `/tmp/build_525edc25a2d8011b4a9bac0dd8c39611/node_modules/firebird/build'
   gyp ERR! build error 
   gyp ERR! stack Error: `make` failed with exit code: 2
   gyp ERR! stack     at ChildProcess.onExit (/tmp/build_525edc25a2d8011b4a9bac0dd8c39611/vendor/node/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
   gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
   gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
   gyp ERR! System Linux 3.8.11-ec2
   gyp ERR! command "node" "/tmp/build_525edc25a2d8011b4a9bac0dd8c39611/vendor/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
   gyp ERR! cwd /tmp/build_525edc25a2d8011b4a9bac0dd8c39611/node_modules/firebird
   gyp ERR! node -v v0.10.33
   gyp ERR! node-gyp -v v1.0.1
   gyp ERR! not ok 

   npm ERR! [email protected] install: `node-gyp rebuild`
   npm ERR! Exit status 1
   npm ERR! 
   npm ERR! Failed at the [email protected] install script.
   npm ERR! This is most likely a problem with the firebird package,
   npm ERR! not with npm itself.
   npm ERR! Tell the author that this fails on your system:
   npm ERR!     node-gyp rebuild
   npm ERR! You can get their info via:
   npm ERR!     npm owner ls firebird
   npm ERR! There is likely additional logging output above.
   npm ERR! System Linux 3.8.11-ec2
   npm ERR! command "/tmp/build_525edc25a2d8011b4a9bac0dd8c39611/vendor/node/bin/node" "/tmp/build_525edc25a2d8011b4a9bac0dd8c39611/vendor/node/bin/npm" "install" "--userconfig" "/tmp/build_525edc25a2d8011b4a9bac0dd8c39611/.npmrc" "--production"
   npm ERR! cwd /tmp/build_525edc25a2d8011b4a9bac0dd8c39611
   npm ERR! node -v v0.10.33
   npm ERR! npm -v 1.4.28
   npm ERR! code ELIFECYCLE
   npm ERR! not ok code 0

Firebird 3.0 connection problem

Hi;

I'm try to connect firebird 3.0.0.31369 (Win32) but i'm getting this error;

Error: connect ECONNREFUSED
    at errnoException (net.js:904:11)
    at Object.afterConnect [as oncomplete] (net.js:895:19)
Firebird.attach(options, function(err, db) {
   if (err)
        throw err;
});

Connection Id

How do I get the value of the Connection Id?

Thanks.

pool.destroy() is not working

Got this simple code and it is dying on the destroy(). I'm using the latest node-firebird (0.2.1).

var spool;
SetLender = function(host, port) {
spool = fb.pool(2, config);
spool.detach();
spool.destroy();
...

Console message is:
/home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:1321
pool.db.push(db);
^
TypeError: Cannot call method 'push' of null
at /home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:1321:21
at cb (/home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:1772:13)
at doCallback (/home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:915:5)
at Socket. (/home/eric/local/node/jstrap/node_modules/node-firebird/lib/index.js:1536:17)

Take the destroy() call out and it works fine.

Question - how to handle binary blobs,

Hi
With a blob defines sub_type 0,
I Try [fs.createReadStream('/tmp/abc.png')]
I Try [fs.createReadStream('/tmp/abc.png',{ encoding: null})]

But always in the database it is trying to convert the binary to a UTF.

The question is how to handle true binary data?

CHARACTER SET UTF8 is not defined

I am attempting to connect to a firebird database running in windows from a linux client, and when trying to attach the database I get the following error:

"bad parameters on attach or create database, CHARACTER SET UTF8 is not defined"

I have googled and searched the answers here but can't seem to find a solution.

How to catch sql error message ?

Hi execute command result is
{ handle: 0,
status:
[ { gdscode: 335544569 },
{ gdscode: 335544436, params: [Object] },
{ gdscode: 335544634, params: [Object] },
{ gdscode: 335544382, params: [Object] } ],
sqlcode: -104 }

on error. How to catch error message this object ?

date format

var today = Date.today().toFormat('DD.MM.YYYY');
console.log(today); // 16.10.2014
database.query("INSERT INTO g_sessions ( user_id, expired, session_id ) VALUES (?,?,?)",
    [data.id, today, session_id],
    function(err, result) {
        console.log('congratulations!');
    }
);

work when date format is 'YYYY-MM-DD'.
but when i send params: [data.id, '16.10.2014', session_id] - all is well =)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.