-
Notifications
You must be signed in to change notification settings - Fork 4k
sql: add support for EXECUTE SCHEDULE statement #158694
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
base: master
Are you sure you want to change the base?
sql: add support for EXECUTE SCHEDULE statement #158694
Conversation
11fc91a to
00cb4ff
Compare
41d83fa to
6cb1c5e
Compare
rafiss
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i only had minor comments, this lgtm!
could you post this PR in #db-jobinfra-eng on Slack as well to check if they have any feedback?
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @dt, @mw5h, and @spilchen)
pkg/sql/parser/testdata/control_job line 642 at r1 (raw file):
parse EXECUTE SCHEDULES SELECT 123
can we also verify that EXECUTE SCHEDULE SELECT 123 (the non-plural variant) parses?
pkg/sql/parser/lexer.go line 330 at r1 (raw file):
lval.id = FOR_JOB } case EXECUTE:
i think we need to add "execute" to the lookaheadKeywords slice:
cockroach/pkg/sql/parser/lexer.go
Line 228 in 9c110b4
| // If you update these cases, update lexbase.lookaheadKeywords. |
IIRC, this is needed to correctly handle objects that have the name "execute"
Add a new SQL statement 'EXECUTE SCHEDULE <schedule_id>' to execute a scheduled job immediately. This reuses the existing logic from ALTER BACKUP SCHEDULE ... EXECUTE IMMEDIATELY, but generalizes it to support any scheduled job. This functionality is particularly useful for TTL jobs, allowing users to trigger them on demand. The <schedule_id> can be a literal or a subquery (e.g., from SHOW SCHEDULES). If multiple are provided, you must use EXECUTE SCHEDULES. Resolves: cockroachdb#146723 Epic: none Release note (sql change): Added support for EXECUTE SCHEDULE <schedule_id> to allow immediate execution of a scheduled job.
6cb1c5e to
945b3ec
Compare
spilchen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I posted it to #db-jobinfra-eng
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @dt, @mw5h, and @rafiss)
pkg/sql/parser/lexer.go line 330 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
i think we need to add "execute" to the
lookaheadKeywordsslice:cockroach/pkg/sql/parser/lexer.go
Line 228 in 9c110b4
// If you update these cases, update lexbase.lookaheadKeywords. IIRC, this is needed to correctly handle objects that have the name "execute"
Hmm, it was added already. See update to pkg/sql/lexbase/predicates.go
pkg/sql/parser/testdata/control_job line 642 at r1 (raw file):
Previously, rafiss (Rafi Shamim) wrote…
can we also verify that
EXECUTE SCHEDULE SELECT 123(the non-plural variant) parses?
Done.
rafiss
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @dt and @mw5h)
pkg/sql/parser/lexer.go line 330 at r1 (raw file):
Previously, spilchen wrote…
Hmm, it was added already. See update to pkg/sql/lexbase/predicates.go
Oops, I must have confused myself looking at my local diff
Add a new SQL statement 'EXECUTE SCHEDULE <schedule_id>' to execute a scheduled job immediately. This reuses the existing logic from ALTER BACKUP SCHEDULE ... EXECUTE IMMEDIATELY, but generalizes it to support any scheduled job.
This functionality is particularly useful for TTL jobs, allowing users to trigger them on demand.
The <schedule_id> can be a literal or a subquery (e.g., from SHOW SCHEDULES). If multiple are provided, you must use EXECUTE SCHEDULES.
Resolves: #146723
Epic: none
Release note (sql change): Added support for EXECUTE SCHEDULE <schedule_id> to allow immediate execution of a scheduled job.