mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
tests + adjustment to halt error message
This commit is contained in:
parent
9048ad398b
commit
b3351dc709
3 changed files with 46 additions and 14 deletions
|
@ -22,9 +22,9 @@ use super::select::emit_simple_count;
|
|||
use super::subquery::emit_subqueries;
|
||||
use crate::error::SQLITE_CONSTRAINT_PRIMARYKEY;
|
||||
use crate::function::Func;
|
||||
use crate::schema::{Index, IndexColumn, Schema};
|
||||
use crate::translate::main_loop::EphemeralCtx;
|
||||
use crate::schema::Schema;
|
||||
use crate::translate::compound_select::emit_program_for_compound_select;
|
||||
use crate::translate::main_loop::EphemeralCtx;
|
||||
use crate::translate::plan::{DeletePlan, Plan, Search};
|
||||
use crate::translate::values::emit_values;
|
||||
use crate::util::exprs_are_equivalent;
|
||||
|
@ -852,20 +852,20 @@ fn emit_update_insns(
|
|||
|
||||
// Check if rowid was provided (through INTEGER PRIMARY KEY as a rowid alias)
|
||||
|
||||
let rowid_alias_index = {
|
||||
let rowid_alias_index = table_ref.columns().iter().position(|c| c.is_rowid_alias);
|
||||
if let Some(index) = rowid_alias_index {
|
||||
plan.set_clauses.iter().position(|(idx, _)| *idx == index)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
let rowid_set_clause_reg = if rowid_alias_index.is_some() {
|
||||
let rowid_alias_index = table_ref.columns().iter().position(|c| c.is_rowid_alias);
|
||||
|
||||
let has_user_provided_rowid = if let Some(index) = rowid_alias_index {
|
||||
plan.set_clauses.iter().position(|(idx, _)| *idx == index)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.is_some();
|
||||
|
||||
let rowid_set_clause_reg = if has_user_provided_rowid {
|
||||
Some(program.alloc_register())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let has_user_provided_rowid = rowid_alias_index.is_some();
|
||||
|
||||
let check_rowid_not_exists_label = if has_user_provided_rowid {
|
||||
Some(program.allocate_label())
|
||||
|
|
|
@ -130,9 +130,9 @@ impl<'a> EphemeralCtx<'a> {
|
|||
name: Some("rowid".to_string()),
|
||||
ty: Type::Integer,
|
||||
ty_str: "INTEGER".to_string(),
|
||||
primary_key: false,
|
||||
primary_key: true,
|
||||
is_rowid_alias: false,
|
||||
notnull: false,
|
||||
notnull: true,
|
||||
default: None,
|
||||
unique: false,
|
||||
collation: None,
|
||||
|
|
|
@ -221,3 +221,35 @@ do_execsql_test_in_memory_any_error update_primary_key_constraint_error {
|
|||
INSERT INTO eye VALUES (78255586.9204539, x'651061e8', 'World perhaps.', -5815764.49018679, 1917);
|
||||
UPDATE eye SET election = 6150;
|
||||
}
|
||||
|
||||
do_execsql_test_in_memory_any_error update_primary_key_constraint_error_2 {
|
||||
CREATE TABLE eye (study REAL, spring BLOB, save TEXT, thank REAL, election INTEGER, PRIMARY KEY (election));
|
||||
INSERT INTO eye VALUES (183559032.521585, x'6625d092', 'Trial six should.', 2606132742.43174, 2817);
|
||||
INSERT INTO eye VALUES (78255586.9204539, x'651061e8', 'World perhaps.', -5815764.49018679, 1917);
|
||||
INSERT INTO eye VALUES (53.3274327094467, x'f574c507', 'Senior wish degree.', -423.432750526747, 2650);
|
||||
INSERT INTO eye VALUES (-908148213048.983, x'6d812051', 'Possible able.', 101.171781837336, 4100);
|
||||
INSERT INTO eye VALUES (-572332773760.924, x'd7a4d9fb', 'Money catch expect.', -271065488.756746, 4667);
|
||||
UPDATE eye SET election = 6150 WHERE election != 1917;
|
||||
}
|
||||
|
||||
do_execsql_test_in_memory_any_error update_primary_key_constraint_error_3 {
|
||||
CREATE TABLE eye (study REAL, spring BLOB, save TEXT, thank REAL, election INTEGER, PRIMARY KEY (election));
|
||||
INSERT INTO eye VALUES (183559032.521585, x'6625d092', 'Trial six should.', 2606132742.43174, 2817);
|
||||
INSERT INTO eye VALUES (78255586.9204539, x'651061e8', 'World perhaps.', -5815764.49018679, 1917);
|
||||
INSERT INTO eye VALUES (53.3274327094467, x'f574c507', 'Senior wish degree.', -423.432750526747, 2650);
|
||||
INSERT INTO eye VALUES (-908148213048.983, x'6d812051', 'Possible able.', 101.171781837336, 4100);
|
||||
INSERT INTO eye VALUES (-572332773760.924, x'd7a4d9fb', 'Money catch expect.', -271065488.756746, 4667);
|
||||
UPDATE eye SET election = 6150 WHERE election > 1000 AND study > 1;
|
||||
}
|
||||
|
||||
do_execsql_test_in_memory_any_error update_primary_key_constraint_error_4 {
|
||||
CREATE TABLE t(a PRIMARY KEY INTEGER, b UNIQUE);
|
||||
INSERT INTO t(b) VALUES (100), (200), (300);
|
||||
UPDATE t SET a = 1;
|
||||
}
|
||||
|
||||
do_execsql_test_in_memory_any_error update_primary_key_unique_constraint_error {
|
||||
CREATE TABLE t(a PRIMARY KEY INTEGER, b UNIQUE);
|
||||
INSERT INTO t(b) VALUES (100), (200), (300);
|
||||
UPDATE t SET b = 2;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue