[CONJS-239] When using connection with callback, pre-commands might be executed after requested query Created: 2023-01-30  Updated: 2023-02-02  Resolved: 2023-02-02

Status: Closed
Project: MariaDB Connector/node.js
Component/s: other
Affects Version/s: None
Fix Version/s: 3.1.0

Type: Bug Priority: Major
Reporter: Diego Dupin Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None


 Description   

There can be multiple pre-commands:

  • setting timezone (option `timezone`)
  • requesting server version by command, not trusting initial handshake (option `forceVersionCheck`)
  • executing initial queries (option `initSql`)
  • setting default query timeout (option `queryTimeout`)

When using callback connection, other commands can be programmed by application before connection is really established. In this particular case, the pre-commands might not be executed still.

example :

  const mariadb = require('mariadb/callback');
  const conn = mariadb.createConnection({host: 'mydb.com', user:'myUser', password: 'myPwd'});
  conn.query("SELECT 1 as val", (err, rows) => { ...}

conn is a connection object, but authentication isn't still done (it will only be done when 'connect' event is emited)

Correction is to ensure pre-command are executed before any "quick commands"


Generated at Thu Feb 08 03:23:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.