mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-17 08:34:19 +01:00
Merge 'Fix self-insert SUM when table uses INTEGER PRIMARY KEY' from Duy Dang
Close #3868 Closes #3870
This commit is contained in:
@@ -1478,7 +1478,12 @@ fn translate_rows_multiple<'short, 'long: 'short>(
|
||||
let translate_value_fn =
|
||||
|prg: &mut ProgramBuilder, value_index: usize, column_register: usize| {
|
||||
if let Some(temp_table_ctx) = temp_table_ctx {
|
||||
prg.emit_column_or_rowid(temp_table_ctx.cursor_id, value_index, column_register);
|
||||
prg.emit_insn(Insn::Column {
|
||||
cursor_id: temp_table_ctx.cursor_id,
|
||||
column: value_index,
|
||||
dest: column_register,
|
||||
default: None,
|
||||
});
|
||||
} else {
|
||||
prg.emit_insn(Insn::Copy {
|
||||
src_reg: yield_reg + value_index,
|
||||
|
||||
@@ -24,6 +24,15 @@ do_execsql_test_on_specific_db {:memory:} strict-basic-creation {
|
||||
SELECT * FROM test1;
|
||||
} {1|item1|10.5}
|
||||
|
||||
do_execsql_test_on_specific_db {:memory:} self-insert-sum-pk {
|
||||
CREATE TABLE t(a INTEGER PRIMARY KEY, b INTEGER);
|
||||
INSERT INTO t(b) VALUES(1),(2);
|
||||
INSERT INTO t(b) SELECT sum(b) FROM t;
|
||||
SELECT a, b FROM t ORDER BY a;
|
||||
} {1|1
|
||||
2|2
|
||||
3|3}
|
||||
|
||||
# Reproducer for https://github.com/tursodatabase/turso/issues/2822
|
||||
do_execsql_test_on_specific_db {:memory:} strict-type-case-insensitivity {
|
||||
CREATE TABLE test1 (id integer, name text, price real) STRICT;
|
||||
|
||||
Reference in New Issue
Block a user