From 12c0b63b87a7b9f75ede0802dbdb0a49c61d8b54 Mon Sep 17 00:00:00 2001 From: Luke Boswell Date: Thu, 24 Sep 2026 10:22:21 +1000 Subject: [PATCH] Avoid recursive result inference hang in SQLite row decoding --- platform/Sqlite.roc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/platform/Sqlite.roc b/platform/Sqlite.roc index 18c04c8b..3600f04e 100644 --- a/platform/Sqlite.roc +++ b/platform/Sqlite.roc @@ -151,15 +151,19 @@ Sqlite :: [].{ ## Execute a SQL query and decode exactly one row into a value. `bindings` ## is a `List(Binding)` and `row` is a decoder built from the functions below. query! = |{ path, query: q, bindings, row }| { - stmt = prepare!({ path, query: q })? - stmt.query!(bindings, row) + match prepare!({ path, query: q }) { + Err(e) => Err(e) + Ok(stmt) => stmt.query!(bindings, row) + } } ## Execute a SQL query and decode multiple rows into a list of values. ## `bindings` is a `List(Binding)` and `rows` is a row decoder. query_many! = |{ path, query: q, bindings, rows }| { - stmt = prepare!({ path, query: q })? - stmt.query_many!(bindings, rows) + match prepare!({ path, query: q }) { + Err(e) => Err(e) + Ok(stmt) => stmt.query_many!(bindings, rows) + } } # ---- Row decoding combinators ---------------------------------------------- @@ -393,13 +397,15 @@ decode_rows! = |stmt, gen_decode| { cols = sqlite_columns!(stmt) decode_row! = gen_decode(cols) helper! = |out| - match sqlite_step!(stmt)? { - Done => Ok(out) - Row => { - row = decode_row!(stmt)? - helper!(out.append(row)) + match sqlite_step!(stmt) { + Err(e) => Err(e) + Ok(Done) => Ok(out) + Ok(Row) => + match decode_row!(stmt) { + Err(e) => Err(e) + Ok(row) => helper!(out.append(row)) + } } - } helper!([]) }