-
Notifications
You must be signed in to change notification settings - Fork 602
Add CREATE TRIGGER
support for SQL Server
#1810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aharpervc
wants to merge
2
commits into
apache:main
Choose a base branch
from
aharpervc:mssql-create-trigger
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
aharpervc
commented
Apr 11, 2025
39517ce
to
b94916f
Compare
b94916f
to
bd6d624
Compare
This fails to parse on this branch, but should:
Fixed, never mind |
FYI for reviewers I rebased this on the create function branch, due to the return statement logic here: #1808 (comment) |
bd6d624
to
aaa2ab3
Compare
77776fc
to
d5d376e
Compare
- similar to functions & procedures, this dialect can define triggers with a multi statement block - there's no `EXECUTE` keyword here, so that means the `exec_body` used by other dialects becomes an `Option`, and our `statements` is also optional for them
d5d376e
to
d2b564d
Compare
Rebased again now that #1808 has been merged. Should be ready for review. |
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.
Adjacent to: #1808 with similar considerations, and temporarily rebased on it (eg, this branch should probably wait for that branch to merge).
This PR introduces support for parsing
CREATE TRIGGER
for SQL Server.The main concern is that for the existing dialects, there was an expectation of an
EXECUTE
keyword (PG: https://www.postgresql.org/docs/current/sql-createtrigger.html). However, SQL Server doesn't use this syntax and instead supports multi statement blocks (like a stored procedure).The difficulty here in the codebase is what to do about CreateTrigger.exec_body & TriggerExecBody. In this iteration I made the property an
Option
, which seemed like the least impact on existing code. TriggerExecBody, etc can be left alone.However in the future I think this could be improved with a more broad refactoring, such as a TriggerBody enum, which can consolidate TriggerExecBodyType's options & use
Vec<Statements>
for aMultiStatement
variant andFunctionDesc
forFunction
&Procedure
variants. That'd basically remove the TriggerExecBody struct, too. Overall I think that'd be a cleaner approach for the CreateTrigger struct.That's all speculative followup work, for now I just want to be able to parse most SQL Server triggers. Other SQL Server specific things like particular trigger options, DDL trigger stuff, etc can come later as needed.