Skip to content

Latest commit

 

History

History
133 lines (117 loc) · 7.28 KB

File metadata and controls

133 lines (117 loc) · 7.28 KB

Oracle Splitter Production Coverage

Phase 1: Ordinary SQL Boundaries

  • Empty input returns no segments.
  • Whitespace-only input returns no segments.
  • Comment-only input returns no segments.
  • A single semicolon-terminated SQL statement returns one segment without the delimiter.
  • A single SQL statement without a semicolon returns one segment.
  • Multiple semicolon-terminated SQL statements return separate segments.
  • Mixed terminated and unterminated SQL statements return separate segments.
  • Consecutive semicolons do not produce empty segments.
  • Leading whitespace before SQL is preserved in segment text and range.
  • Inter-statement whitespace is attached to the following segment unless it is consumed as a SQL*Plus line-command delimiter.
  • Trailing whitespace after the final statement is preserved in the final segment.
  • CRLF line endings do not corrupt boundaries.
  • UTF-8 comments do not corrupt byte ranges.
  • Arithmetic division does not act as a slash delimiter.
  • Schema-qualified and dblink-qualified names do not affect splitting.

Phase 2: Literals, Identifiers, Comments, and Hints

  • Semicolons inside single-quoted string literals are ignored.
  • Slashes inside single-quoted string literals are ignored.
  • Escaped single quotes using doubled quotes are handled.
  • National character literals N'...' are handled.
  • Oracle q'[ ... ]' quoting is handled.
  • Oracle q'{ ... }' quoting is handled.
  • Oracle q'( ... )' quoting is handled.
  • Oracle q'< ... >' quoting is handled.
  • Oracle custom q'!...!' quoting is handled.
  • Semicolons inside double-quoted identifiers are ignored.
  • Slashes inside double-quoted identifiers are ignored.
  • Line comments containing semicolons are ignored.
  • Line comments containing slash-only visual markers are ignored.
  • Block comments containing semicolons are ignored.
  • Block comments containing slash-only lines are ignored.
  • Nested block comments are handled.
  • Hints /*+ ... */ containing delimiters are ignored for splitting.

Phase 3: SQL*Plus Slash and Buffer Commands

  • A slash alone on a line flushes the current SQL segment.
  • A slash line with surrounding horizontal whitespace flushes the current SQL segment.
  • A slash at EOF flushes the current SQL segment.
  • A slash followed by non-whitespace on the same line is not a delimiter.
  • A slash preceded by non-whitespace on the same line is not a delimiter.
  • RUN alone on a line flushes the current SQL segment.
  • R alone on a line flushes the current SQL segment.
  • Slash commands with leading command lines before SQL do not produce empty segments.
  • Multiple slash commands in a row do not produce empty segments.
  • Slash commands after PL/SQL units do not appear in segment text.

Phase 4: Anonymous PL/SQL Blocks

  • BEGIN ... END; is returned as one segment.
  • DECLARE ... BEGIN ... END; is returned as one segment.
  • Labeled anonymous blocks are returned as one segment.
  • Nested anonymous blocks do not split at inner semicolons.
  • Exception handlers do not split the outer block.
  • IF ... END IF; stays inside the block.
  • CASE ... END CASE; stays inside the block.
  • LOOP ... END LOOP; stays inside the block.
  • WHILE ... LOOP ... END LOOP; stays inside the block.
  • FOR ... LOOP ... END LOOP; stays inside the block.
  • FORALL statements stay inside the block.
  • Dynamic SQL strings containing semicolons stay inside the block.

Phase 5: Stored PL/SQL Units

  • CREATE PROCEDURE ... END; / is one segment.
  • CREATE OR REPLACE PROCEDURE ... END; / is one segment.
  • CREATE EDITIONABLE PROCEDURE ... END; / is one segment.
  • CREATE NONEDITIONABLE PROCEDURE ... END; / is one segment.
  • CREATE FUNCTION ... END; / is one segment.
  • Function bodies with arithmetic division do not split at /.
  • CREATE PACKAGE ... END; / is one segment.
  • CREATE PACKAGE BODY ... END; / is one segment.
  • Package body nested procedure bodies do not terminate the package.
  • Package body nested function bodies do not terminate the package.
  • CREATE TRIGGER ... BEGIN ... END; / is one segment.
  • Compound triggers are one segment.
  • CREATE TYPE BODY ... END; / is one segment.
  • Type body member function bodies do not terminate the type body.
  • Stored units followed by ordinary SQL split correctly.

Phase 6: SQL*Plus Line Commands

  • SET command lines are returned as line segments.
  • SHOW command lines are returned as line segments.
  • PROMPT command lines are returned as line segments, including embedded semicolons.
  • SPOOL command lines are returned as line segments.
  • COLUMN command lines are returned as line segments.
  • BREAK command lines are returned as line segments.
  • COMPUTE command lines are returned as line segments.
  • TTITLE and BTITLE command lines are returned as line segments.
  • REPHEADER and REPFOOTER command lines are returned as line segments.
  • DEFINE and UNDEFINE command lines are returned as line segments.
  • ACCEPT command lines are returned as line segments.
  • VARIABLE and PRINT command lines are returned as line segments.
  • EXECUTE command lines are returned as line segments.
  • CONNECT and DISCONNECT command lines are returned as line segments.
  • EXIT and QUIT command lines are returned as line segments.
  • WHENEVER SQLERROR command lines are returned as line segments.
  • WHENEVER OSERROR command lines are returned as line segments.
  • @, @@, and START script invocation lines are returned as line segments.
  • REM and REMARK command lines are returned as line segments.
  • HOST and ! shell command lines are returned as line segments.
  • Buffer manipulation commands LIST, APPEND, CHANGE, DEL, INPUT, SAVE, GET, and EDIT are returned as line segments.
  • SQL*Plus command words inside SQL are not treated as line commands.
  • SQL*Plus command words inside PL/SQL are not treated as line commands.

Phase 7: Soft-Fail and Safety

  • Unterminated single-quoted strings do not panic.
  • Unterminated q-quotes do not panic.
  • Unterminated double-quoted identifiers do not panic.
  • Unterminated block comments do not panic.
  • Missing PL/SQL END returns a best-effort trailing segment.
  • Truncated CREATE PROCEDURE returns a best-effort trailing segment.
  • Binary-ish bytes do not panic.
  • Every returned segment has a valid non-overlapping byte range.
  • Every returned segment text equals input[ByteStart:ByteEnd].
  • Reconstructing returned ranges includes SQL*Plus command lines as their own segments.

Phase 8: Facade Integration

  • oracle.Parse parses splitter output from ordinary SQL scripts.
  • oracle.Parse parses splitter output from slash-terminated PL/SQL scripts.
  • oracle.Parse returns parser errors for SQL*Plus command segments instead of silently skipping them.
  • oracle.Parse preserves original byte offsets in AST locations.
  • oracle.Parse reports start line and column based on the original script.
  • oracle.Parse handles multiple ordinary SQL statements around slash-delimited PL/SQL blocks.