0

I am having to integrate with a Firebird 1.5 database. We can't upgrade the DB to a newer version.

I run the below code to attempt to see what the tables are

var Firebird = require('node-firebird');

var options = {};

options.host = '127.0.0.1';
options.port = 3050;
options.database = 'C:\\Database.fdb';
options.user = 'sysdba';
options.password = 'masterkey';
options.lowercase_keys = false; // set to true to lowercase keys
options.role = null;            // default
options.pageSize = 4096;        // default when creating database
options.pageSize = 4096;        // default when creating database
options.retryConnectionInterval = 1000; // reconnect interval in case of connection drop

Firebird.attach(options, function(err, db) {
    console.log("starting");
    if (err) {
        console.log(err)
        throw err;
    }
    
    // db = DATABASE
    db.execute('show tables', function(err, result) {
        // IMPORTANT: close the connection
        console.log(err)
        console.log(result)
        db.detach();
    });

});

The above results in the following error:

Error: Dynamic SQL Error, SQL error code = -104, Token unknown - line 1, column 1, show
    at doCallback (C:\nodetest\node_modules\node-firebird\lib\index.js:1321:21)
    at C:\nodetest\node_modules\node-firebird\lib\index.js:3100:25
    at C:\nodetest\node_modules\node-firebird\lib\messages.js:151:25
    at search (C:\nodetest\node_modules\node-firebird\lib\messages.js:117:13)
    at C:\nodetest\node_modules\node-firebird\lib\messages.js:54:21
    at FSReqCallback.wrapper [as oncomplete] (node:fs:675:5) {
  gdscode: 335544569,
  gdsparams: undefined
}

Changing just the query in the code to a select on a table I know should exist

select first 1 * from tag

Just sits hanging as if the code is stuck trying to read the table.

Is there anything obvious I'm doing wrong? Or is there a different way we should be connecting to this database?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Mudders
  • 127
  • 2
  • 12
  • First of all try to `path.resolve` the path to database. The library is too prone to fail on this stage – Jaood_xD Sep 14 '22 at 09:46
  • Also I've used login `SYSDBA` in upper case, not sure that this one could help, but give it a try. – Jaood_xD Sep 14 '22 at 09:48
  • @Jaood_xD - I tried using path.resolve to ensure the path was correct - same error. I also tried the SYSDBA in upper case - same error. Thanks for the suggestions. – Mudders Sep 14 '22 at 10:56
  • Accordingly to the answer [here](https://stackoverflow.com/a/37070117/18891587) your issue could be related to firebird version. – Jaood_xD Sep 14 '22 at 11:02
  • @Jaood_xD User names in Firebird 1.5 are case-insensitive, since Firebird 3.0 they can be case-sensitive *if* enclosed in double quotes. – Mark Rotteveel Sep 15 '22 at 05:59

1 Answers1

2

Firebird doesn't have a show tables statement. That is a command specific to the Firebird isql query tool. To query for tables, you need to query the metadata tables, e.g.

select RDB$RELATION_NAME from RDB$RELATIONS

(note: this will also includes views, to exclude them add condition where RDB$VIEW_BLR is null)

As an aside, Firebird 1.5 has been end-of-life since October 2009. Several security issues have been solved in newer versions. You should really upgrade to a newer version.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197