Skip to content

Run a statement through one runner so every error reaches the caller, and key the statement cache on every compile option #2652

Open
0 of 3 issues completed

Description

@mathiasrw

What happens today

What to change

  1. Add runQuery(run, ctx) in src/select/queryfn.js. It opens every source through the source interface of Give file sources one source interface that opens rows for a run and reports errors in one place #2677 (open(ctx) gives an array or a promise of one). When every source gave an array it continues at once, otherwise it waits with Promise.all and continues along the same path. Remove queryfn2 and the sourceslen counter.
  2. Wrap everything after the sources in one try in the runner. With a callback the error goes to cb(null, err) once, without one it is thrown.
  3. alasql.adrun stops at the first statement that reports an error and passes the error to the callback.
  4. Add cacheKey(sql) in src/engine/core.js that joins the SQL text with joinstar, casesensitive, valueof, autocommit and cache, and use it for db.sqlCache and db.astCache. Keep the option names in one list with a comment that a new compile-time option belongs in it.

What stays the same

Done when

  • A new test file named after this issue checks that alasql.promise rejects, within a time limit, for an error in a user function, in ORDER BY and in a scalar subquery over a file source, and for the second of two statements, and that the callback form gets the error once.
  • The same file switches each option in the cache key between two runs of the same SQL text and checks that the second run matches a run with the cache off.
  • The full test suite and the CI checks (dialect test, parity check, run-state check, binding check) pass, and the pull request lists every parity difference.

Fixes

Fixes #3155, #3156, #3157.

Depends on

#2677

Sub-issues

Sub-issues

0 of 3 Issues completed
Loading 3 sub-issues

Activity

  1. mathiasrw commented on Oct 20, 2026

    @mathiasrw
    MemberAuthor

    Measured while reviewing #909, on develop: with alasql.options.casesensitive = false, run SELECT Name FROM ? over [{Name: "x"}] (gives [{}], the name is lowercased). Set casesensitive = true and run the same text again: still [{}], because the cached statement was compiled with the lowercased name. A fresh process with casesensitive = true gives [{Name: "x"}].

  2. added this to the v4.x Focus milestone on Nov 26, 2026
  3. changed the title [-]Review #2312 for code improvements: one option in the statement cache key[/-] [+]Run a statement through one runner so every error reaches the caller, and key the statement cache on every compile option[/+] on Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions