Skip to content

Conversation

joaostorrer
Copy link
Contributor

This is quite a big one.
It adds support for Oracle PL/SQL objects like Procedures, Functions, Types, Packages, Anonymous Blocks, If statements, Case statements, Loops, Cursors and Collections.

Some objects were copied from T-SQL dialect.

The tests statements were copied from the official Oracle PL/SQL Documentation

Closes #1217.
Closes #6568.

Brief summary of the change made

Are there any other side effects of this change that we should be aware of?

Pull Request checklist

  • Please confirm you have completed any of the necessary steps below.

  • Included test cases to demonstrate any code changes, which may be one or more of the following:

    • .yml rule test cases in test/fixtures/rules/std_rule_cases.
    • .sql/.yml parser test cases in test/fixtures/dialects (note YML files can be auto generated with tox -e generate-fixture-yml).
    • Full autofix test cases in test/fixtures/linter/autofix.
    • Other.
  • Added appropriate documentation for the change.

  • Created GitHub issues for any relevant followup/future enhancements if appropriate.

Copy link
Contributor

github-actions bot commented Feb 6, 2025

Coverage Results ✅

Name    Stmts   Miss  Cover   Missing
-------------------------------------
TOTAL   19499      0   100%

248 files skipped due to complete coverage.

…ype of class `CreateTriggerStatementSegment` to `create_trigger_statement`.
OneOf("IS", "AS", optional=True),
AnyNumberOf(Ref("DeclareSegment"), optional=True),
Ref("BeginEndSegment", optional=True),
Ref("DelimiterGrammar", optional=True),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need to be kept, because procedures can be declared inside DeclareSegment and CreatePackageStatementSegment. If I remove it the parser raises an error.

Dedent,
"END",
Ref("ObjectReferenceSegment", optional=True),
Ref("DelimiterGrammar", optional=True),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about this one - is it a statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a statement, it's an anonymous block. Oracle don't define it as a statement.
Removed the DelimiterGrammar.

OneOf("IS", "AS", optional=True),
AnyNumberOf(Ref("DeclareSegment"), optional=True),
Ref("BeginEndSegment", optional=True),
Ref("DelimiterGrammar", optional=True),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This need to be kept, because functions can be declared inside DeclareSegment and CreatePackageStatementSegment. If I remove it the parser raises an error.

"BEGIN",
Ref("OneOrMoreStatementsGrammar"),
Sequence("END", Ref("TimingPointGrammar")),
Ref("DelimiterGrammar"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need a delimiter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it does, because it's part of the trigger block. If I remove this delimiter the parser thinks it's the end of the trigger and raises an error.

@WittierDinosaur
Copy link
Contributor

Nearly there, just one final merge conflict

@joaostorrer
Copy link
Contributor Author

Done.
I had to keep the keywords DELETING, INSERTING, LOOP, UPDATING and WITH as reserved, even if they don't appear as reserved in the oracle docs so Sqlfluff don't think it is a SingleIdentiferGrammar in ExitStatementSegment and LoopStatementSegment.

Copy link
Contributor

@WittierDinosaur WittierDinosaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@WittierDinosaur WittierDinosaur added this pull request to the merge queue Mar 29, 2025
Merged via the queue into sqlfluff:main with commit 9e29b2f Mar 29, 2025
28 checks passed
@joaostorrer joaostorrer deleted the oracle_plsql branch March 31, 2025 14:30
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.

Oracle: unparsable section CREATE OR REPLACE TRIGGER Support of Oracle PLSQL?
2 participants