Skip to content

Run UPDATE, DELETE and INSERT on a parameter array without a temporary table #2682

Open
0 of 1 issue completed

Description

@mathiasrw

What happens today

UPDATE ?, DELETE FROM ? and INSERT INTO ? go through yy.compileParamValue (src/engine/yy.js, line 33), called from src/statements/update.js (line 49), src/statements/delete.js (line 38) and src/statements/insert.js (line 87). On every run it adds a table __p<n>_<Date.now()> with the array as data, swaps it into the cached parsed statement, compiles again, runs, copies rows back for DELETE and INSERT, and deletes the table in a finally. The finally runs before an asynchronous INSERT SELECT has finished. This is #3154.

What to change

  1. Compile UPDATE, DELETE and INSERT on ? once, like any other statement. The target is the parameter source of Give file sources one source interface that opens rows for a run and reports errors in one place #2677, whose rows are params[n] with no known columns.
  2. Hand the rows to writeRows (Pass the rows of INSERT, UPDATE and DELETE through one write pipeline #2650) with an array storage added next to the memory table in src/statements/write.js. insert pushes into the array, update replaces the element in place, delete removes elements in place. Keys, checks and triggers do nothing for an array.
  3. Keep the error for a parameter that is not an array (UPDATE requires an array for parameter 0), through the callback when there is one.
  4. Remove yy.compileParamValue.

What stays the same

Done when

  • A new test file named after this issue covers UPDATE, DELETE and INSERT (VALUES and SELECT) on ?, each run twice with different arrays from the same SQL text and from alasql.compile(), with OUTPUT, and INSERT INTO ? SELECT from a file source through alasql.promise rejects with a TypeError #3154. It checks that the array passed in is the one changed.
  • 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 #3154.

Depends on

#2677, #2650

Sub-issues

Sub-issues

0 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added this to the v4.x Focus milestone on Nov 26, 2026
  2. changed the title [-]Review #2349 for code improvements: UPDATE, DELETE and INSERT on ? build a temporary table each run[/-] [+]Run UPDATE, DELETE and INSERT on a parameter array without a temporary table[/+] 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