Skip to content

Review #2349 for code improvements: UPDATE, DELETE and INSERT on ? build a temporary table each run #2682

Open

Description

@mathiasrw

This is not a bug report. It is an invitation to look at #2349 again, because it makes UPDATE ?, DELETE FROM ? and INSERT INTO ? work by building a temporary table on every run. The goal is to understand the change and decide whether anything should be improved. The notes below come from a quick read of the diff and a few runs, not from a full analysis.

The concerns:

  • Each run compiles the statement again around a temporary table. yy.compileParamValue (src/28yy.js) adds a table __p<n>_<Date.now()> to the database, swaps it into the parsed statement (self[refProp]), compiles, runs, copies the rows back into the array and deletes the table. The parsed statement is shared by the statement cache, so it is changed while it is in use.
  • The table is deleted before an asynchronous run finishes. The finally runs as soon as the statement returns. await alasql.promise('INSERT INTO ? SELECT * FROM JSON("j.json")', [arr]) fails with Cannot read properties of undefined (reading 'data').
  • SELECT … FROM ? already reads an array as a source without a table. Letting UPDATE, DELETE and INSERT work on an array source in the same way would avoid the temporary table, the second compile and the copy back.

Related: #2348, #2596.

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions