sql: wire SHOW ROLES extended options into delegate dispatch#168023
Merged
Conversation
Contributor
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Member
457dd23 to
67411c8
Compare
Add grammar rules to sql.y for the SHOW USERS WITH ... syntax:
SHOW USERS WITH SOURCE = <expr>, LAST LOGIN BEFORE <expr> LIMIT <n>
Options are parsed into ShowUsersOptions via the show_users_option
production rule. Multiple options are comma-separated and validated
for duplicates via CombineWith.
Update parser testdata with parse round-trip tests for all clause
combinations.
Epic: CRDB-52460
Release note (sql change): SHOW USERS now supports optional
filtering clauses for user provisioning workflows:
SHOW USERS [WITH <options>] [LIMIT <n>]
Options (comma-separated):
- SOURCE = <string>: filter users by their provisioning source
(PROVISIONSRC role option value), e.g. 'ldap:ldap.example.com'.
- LAST LOGIN BEFORE <timestamp>: filter users whose estimated
last login time is before the given timestamp. Users who have
never logged in (NULL estimated_last_login_time) are excluded.
Examples:
-- Find all LDAP-provisioned users
SHOW USERS WITH SOURCE = 'ldap:ldap.example.com'
-- Find dormant users who haven't logged in since Jan 2024
SHOW USERS WITH LAST LOGIN BEFORE '2024-01-01'
-- Combine filters with a limit
SHOW USERS WITH SOURCE = 'ldap:ldap.example.com',
LAST LOGIN BEFORE '2024-06-01' LIMIT 100
The original SHOW USERS behavior (no clauses) is unchanged.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit connects the SHOW USERS extended syntax (WITH SOURCE, WITH LAST LOGIN BEFORE, LIMIT) to the delegation layer that generates the underlying SQL query. It also adds end-to-end logic tests covering the new filter clauses. Epic: CRDB-45081 Release note: None
Previously, the ShowRoles AST node was an empty struct with no support for filtering or limiting. Since SHOW ROLES and SHOW USERS are interchangeable, extend ShowRoles to include the same Options (*ShowUsersOptions) and Limit fields that ShowUsers already has, along with the corresponding Format logic. This is the first of three parts to extend SHOW ROLES with the same provisioning filter clauses that SHOW USERS supports. Epic: none Release note: None Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactor delegateShowRolesExtended to accept (options, limit) parameters instead of a *tree.ShowUsers, so it can serve both SHOW USERS and SHOW ROLES. Update the delegate dispatcher to pass ShowRoles.Options and ShowRoles.Limit, matching the ShowUsers dispatch path. Remove the TODO comment since the function is now wired into both code paths. Epic: none Release note: None Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
67411c8 to
bc5cc71
Compare
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
delegateShowRolesExtendedto accept(options *ShowUsersOptions, limit *Limit)parameters instead of*tree.ShowUsers, so it can serve both SHOW USERS and SHOW ROLESShowRoles.OptionsandShowRoles.Limitthrough the extended pathTODO(sourav)comment since the function is now wired into both code pathsPart 2 of 3 — depends on #168022.
Informs: CRDB-62959
Epic: none
🤖 Generated with Claude Code