Repository navigation
Open
0 / 10 of 1 issue completedOpen
0 / 10 of 1 issue completed
Copy link
Milestone
Description
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
- 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 areparams[n]with no known columns. - 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 insrc/statements/write.js.insertpushes into the array,updatereplaces the element in place,deleteremoves elements in place. Keys, checks and triggers do nothing for an array. - 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. - Remove
yy.compileParamValue.
What stays the same
- Returned counts, OUTPUT rows and error texts.
- The caller's array object is changed in place.
INSERT INTO ? VALUES (3, 3)still stores[3, 3]as a row.- No temporary table appears in the database during a run.
- Results change only for INSERT INTO ? SELECT from a file source through alasql.promise rejects with a TypeError #3154.
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 fromalasql.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
Sub-issues
Collapse Sub-issuesSub-issues
Loading 1 sub-issues
Activity
[-]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[/+]