oracle: match Oracle's non-nested block comment semantics - #394
Merged
Conversation
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>
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
*/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/*./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).*/, keeping lexer and splitter byte-identical. Hint comments (/*+ ... */) follow the same termination rule, keepingtokHINT.Engine truth (Oracle 11gR2, both directions)
The discriminating pair rules out nesting semantics entirely; the customer's minimal shape also compiles VALID through sqlplus.
Testing
*/, unterminated forms (incl. with inner/*),/*/*/inside strings and line comments, division, minimal customer shape (slash stripped), spec+body package pair./), ending atend pk_reissue;.go test ./oracle/...green; PG splitter untouched (nesting there is correct engine behavior).Issue
BYT-9963
🤖 Generated with Claude Code