Skip to content

oracle: match Oracle's non-nested block comment semantics - #394

Merged
rebelice merged 1 commit into
mainfrom
danny/byt9963-nonnested-comments
Jul 28, 2026
Merged

oracle: match Oracle's non-nested block comment semantics#394
rebelice merged 1 commit into
mainfrom
danny/byt9963-nonnested-comments

Conversation

@rebelice

Copy link
Copy Markdown
Collaborator

Summary

  • Oracle block comments do not nest — the first */ terminates the comment regardless of /* sequences inside it. Both the lexer (lexBlockCommentOrHint) and the splitter's scanner (splitSkipBlockComment) counted nesting depth (PostgreSQL semantics — PG genuinely nests per scan.l, a real per-engine divergence), leaving the scanner in comment state through EOF whenever a commented-out region contained a stray /*.
  • Consequence: the statement terminator and the standalone SQL*Plus / after it were never recognized, and the slash was sent to Oracle inside the statement — PLS-00103, invalid package body (BYT-9963, MBBank, 232KB package with the marker at body-relative line 4584).
  • Fix both scan sites to terminate at the first */, keeping lexer and splitter byte-identical. Hint comments (/*+ ... */) follow the same termination rule, keeping tokHINT.

Engine truth (Oracle 11gR2, both directions)

SELECT 1 /* a /* b */ FROM dual      -- succeeds: comment ends at first */
SELECT 2 /* a /* b */ */ FROM dual   -- ORA-00936: the shape legal only under nesting

The discriminating pair rules out nesting semantics entirely; the customer's minimal shape also compiles VALID through sqlplus.

Testing

  • New fences: both truth directions, hint termination at first */, unterminated forms (incl. with inner /*), /*/*/ inside strings and line comments, division, minimal customer shape (slash stripped), spec+body package pair.
  • Real customer file (231,981 bytes): now splits into 2 SQL segments — seg1 23,402 B (unchanged), seg2 208,574 B (previously 208,577 B with the retained /), ending at end pk_reissue;.
  • go test ./oracle/... green; PG splitter untouched (nesting there is correct engine behavior).

Issue

BYT-9963

🤖 Generated with Claude Code

Oracle block comments do not nest: the first */ terminates the comment
regardless of /* sequences inside it. Both the lexer and the splitter's
comment scanner counted nesting depth (PostgreSQL semantics, where
nesting is genuine scan.l behavior), so a commented-out code region
containing /* left the scanner in comment state through EOF. The
statement terminator and the standalone SQL*Plus slash after it were
never recognized, and the slash was sent to Oracle as part of the
statement — PLS-00103, invalid package body (BYT-9963, 232KB customer
package with the marker at body-relative line 4584).

Engine-verified on 11gR2 in both directions:

    SELECT 1 /* a /* b */ FROM dual      -- succeeds
    SELECT 2 /* a /* b */ */ FROM dual   -- ORA-00936 (legal only if nested)

Fix both scan sites to terminate at the first */ so the lexer and the
splitter stay byte-identical. Hints (/*+ ... */) follow the same rule,
keeping tokHINT. Fences: both truth directions, hint termination,
unterminated forms, /* markers in strings and line comments, division,
the minimal customer shape, and the spec+body package pair; the real
customer file now splits into 2 segments with no retained slash.

Fixes BYT-9963.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rebelice
rebelice merged commit d2f82de into main Jul 28, 2026
23 checks passed
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