Repository navigation
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
Conversation
… a one-statement routine body from swallowing the script, and step Vim by character
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
E',b'andq'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, soSELECT x$e'\'; DROP TABLE t; --'is two statements and Safe Mode sees theDROP. Oracle and Dameng continue one with#too.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 theDROP.begincolumn no longer opens a block that swallows the rest of the script: after aSELECT,INSERT,UPDATE,DELETE,REPLACEorMERGEbody noBEGINopens, and after aRETURNbody one opens only behindASorIS(RETURN INT AS BEGIN). Trigger events (BEFORE INSERT,DELETE ON t,FOR INSERT, UPDATE),IFbodies and DB2'sCOMMIT ON RETURNstay as they were.h,l,x,X,s,r,~,a,p,R, Esc,f/tand 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.fortwith an emoji target no longer crashes.dl,dhandclnow act instead of leaving the operator pending, and a delete leaves the caret on the line's last character, asd$does in Vim.check-sql-lexical-grammar.shgets two U+200B cases.Test plan
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,RETURNheaders, trigger and control headers),SQLStatementSplittingTests.prefixAfterAName,SQLFileParserTests(import splits the same),VimEngineComposedCharacterTests. Each has cases that fail on main.SQLLexicalFeatureMappingTests.everyFactHasAPartnerlists the new curated-only fact and counts 43 bits; its corpus gains three glued-prefix texts.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.