From 2171c5f4e1a602b5a8f75317e16beee87f40e1c0 Mon Sep 17 00:00:00 2001 From: krishvishal Date: Mon, 2 Jun 2025 10:38:11 +0530 Subject: [PATCH] Added apply_affinity_char to fix bugs in `SeekRowId` --- core/vdbe/execute.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/core/vdbe/execute.rs b/core/vdbe/execute.rs index 1e56778b7..72077b551 100644 --- a/core/vdbe/execute.rs +++ b/core/vdbe/execute.rs @@ -2004,13 +2004,22 @@ pub fn op_seek_rowid( let rowid = match state.registers[*src_reg].get_owned_value() { Value::Integer(rowid) => Some(*rowid), Value::Null => None, + // For non-integer values try to apply affinity and convert them to integer. other => { - return Err(LimboError::InternalError(format!( - "SeekRowid: the value in the register is not an integer or NULL: {}", - other - ))); + let mut temp_reg = Register::Value(other.clone()); + let converted = apply_affinity_char(&mut temp_reg, Affinity::Numeric); + if converted { + match temp_reg.get_owned_value() { + Value::Integer(i) => Some(*i), + Value::Float(f) => Some(*f as i64), + _ => unreachable!("apply_affinity_char with Numeric should produce an integer if it returns true"), + } + } else { + None + } } }; + match rowid { Some(rowid) => { let found = return_if_io!(