Skip to content

Unable to EXPLAIN a query with parameters #1243

@merceyz

Description

@merceyz

Running EXPLAIN on a query that contains parameters doesn't seem to work correctly as an error is thrown because the parameters aren't set but that shouldn't be required.

Tested with better-sqlite3 v11.2.1 and Node.js v18.20.4.

Reproduction:

import Database from 'better-sqlite3';

const db = new Database(':memory:');

// Works
console.log(db.prepare('EXPLAIN select 1').all());

// Doesn't work
console.log(db.prepare('EXPLAIN select ?').all());
console.log(db.prepare('EXPLAIN select :foo').all());

Error:

RangeError: Too few parameter values were provided
    at file:///tmp/test.mjs:9:44
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadESM (node:internal/process/esm_loader:34:7)
    at async handleMainPromise (node:internal/modules/run_main:106:12)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions