Repository navigation
fix(v18): throw SqlError from fingerprint, normalize, and scan - #204
pyramation wants to merge 2 commits into
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
This PR ports the parse layer to PostgreSQL 18 and replaces the string-based error path with a structured FFI contract: new C wrapper entry points return a Reviewed commit: 19ebada |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
Devin Review found 1 finding. It is left for you to triage below.
There was a problem hiding this comment.
🟡 SQL error offsets drift after emoji
When an SQL error follows an emoji, callDetailed reports an offset too early for the JavaScript query string. PostgreSQL counts the emoji once, but formatSqlError uses the position as a JavaScript string index.
Devin left this for you to triage: The new methods intentionally match parseSync’s PostgreSQL character offset: for SELECT '😀', 'abc all four report 12, while JavaScript substring indexing locates the quote at 13. Fix the existing formatSqlError indexing separately so this PR preserves the parse contract and stays limited to typed errors.
(Refers to this code)
Learn more
PostgreSQL reports the cursor as a one-based count of Unicode characters. JavaScript indexes strings by UTF-16 code units, so a supplementary character such as an emoji occupies two index positions instead of one. The new structured-error path only changes the base from one to zero. The built-in formatSqlError then uses that offset to position the caret and to truncate the query.
Example: In SELECT '😀', 'abc, PostgreSQL reports position 13 for the unclosed quote. Subtracting one yields 12, which indexes the preceding space in JavaScript; the quote is at index 13.
Recommended fix: In the full template, convert positive PostgreSQL cursor positions to UTF-16 offsets by advancing through the original query by Unicode code point and accumulating each point’s code-unit width. Regenerate the v18 source and add a supplementary-character regression case for the three operations and their sync variants.
Was this helpful? React with 👍 or 👎 to provide feedback.
…sql-errors # Conflicts: # templates/full/wasm_wrapper.c # versions/18/src/wasm_wrapper.c
|
Superseded by #207, which combines the PG18 typed SQL errors and WASM recovery fixes. |
Summary
PG18
fingerprint,normalize, andscannow read structured WASM results, so PostgreSQL failures throwSqlErrorwith the original message, zero-based cursor, and source details. Previously, grammar errors without a recognized prefix could pass as results, and scanner lexer errors could surface as JSONSyntaxError.Regression tests cover sync and async calls for all three operations. WASM allocation failures still use the existing OOM path; successful results are unchanged. This replaces the typed-error portion of #183; scanner JSON escaping is separate.
Implemented in session Throw typed SqlError from fingerprint, normalize and scan
Review with Devin · Open in Devin Desktop
Summary by CodeRabbit