Skip to content

fix(editor): end a name where the engine does before E'' and $$, keep a one-statement routine body from swallowing the script, and step Vim by character - #4236

Merged
datlechin merged 2 commits into
mainfrom
fix/audit-w6-editor-text
Nov 12, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/audit-w6-editor-text

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • E', b' and q' start a literal only where the engine's name rule ends the name before them. PostgreSQL continues a name with $ and every non-ASCII unit, so SELECT x$e'\'; DROP TABLE t; --' is two statements and Safe Mode sees the DROP. Oracle and Dameng continue one with # too.
  • DuckDB blanks U+00A0, U+2000 to U+200B, U+202F, U+205F, U+2060, U+3000 and U+FEFF before it lexes, outside what its pre-lexing pass reads as a quote. New curated fact nonASCIISpacesEndNames: DuckDB splits with it and every gate reads DuckDB text with and without it. SELECT varchar + U+200B + E'\''; DROP TABLE t; --' and the same before $$ no longer hide the DROP.
  • The scanner, SQL import and the kit's lexer read prefixes and dollar quotes with the same rule.
  • In a routine whose body is one statement, a begin column no longer opens a block that swallows the rest of the script: after a SELECT, INSERT, UPDATE, DELETE, REPLACE or MERGE body no BEGIN opens, and after a RETURN body one opens only behind AS or IS (RETURN INT AS BEGIN). Trigger events (BEFORE INSERT, DELETE ON t, FOR INSERT, UPDATE), IF bodies and DB2's COMMIT ON RETURN stay as they were.
  • Vim h, l, x, X, s, r, ~, a, p, R, Esc, f/t and visual mode move and edit by whole characters, so they no longer split an emoji or a letter from its accent. The Vim caret and selection never sit inside a character. f or t with an emoji target no longer crashes.
  • Vim dl, dh and cl now act instead of leaving the operator pending, and a delete leaves the caret on the line's last character, as d$ does in Vim.
  • check-sql-lexical-grammar.sh gets two U+200B cases.

Test plan

  • New: SQLNonCodeSpanTests (prefix and dollar quote after a name on PostgreSQL, CockroachDB, Redshift, DuckDB, Oracle, Dameng, and the DuckDB texts its pre-lexing pass keeps), SQLRoutineBodyNameTests (one-statement bodies, RETURN headers, trigger and control headers), SQLStatementSplittingTests.prefixAfterAName, SQLFileParserTests (import splits the same), VimEngineComposedCharacterTests. Each has cases that fail on main.
  • Changed: SQLLexicalFeatureMappingTests.everyFactHasAPartner lists the new curated-only fact and counts 43 bits; its corpus gains three glued-prefix texts.
  • Measured on PostgreSQL 17.11, the DuckDB 1.5.4 CLI and the shipped DuckDB 2.0.0 library: which non-ASCII units end a name before E' and $$, and where DuckDB keeps one. check-sql-lexical-grammar.sh postgresql duckdb sqlite: every case agrees except SQLite's canonically equivalent dollar tag, which disagrees on main too.
  • TableProCore package tests, the Vim and SQL suites of the Unit plan, AllPlugins, ABI, lint.

… a one-statement routine body from swallowing the script, and step Vim by character
@datlechin
datlechin merged commit 035de0f into main Nov 12, 2026
9 of 10 checks passed
@datlechin
datlechin deleted the fix/audit-w6-editor-text branch November 12, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant