ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

Fix calling FreeColumns multiple times resulting in SIGABRT #980

Closed lasse-it closed 5 months ago

lasse-it commented 5 months ago

Calling the method FreeColumnsmultiple times results in a SIGABRT.

One way to invoke this behaviour is by first calling fetchAlland then getColumnMetadataSync as shown in the example below:

const conn = new Database()
await conn.open(connectionString)
const stmt = await conn.prepare(`SELECT * from "users" WHERE "username" = 'jan' FETCH NEXT 1 ROWS ONLY FOR UPDATE`)
stmt.execute([], async (err, result, outparams) => {
    await result.fetchAll();
    await result.getColumnMetadataSync();
})

I've proposed a fix, where we provide FreeColumns with a reference to the column pointer instead. This way, FreeColumns can set the pointer to NULL once it's deleted.