Skip to content

sql: wire SHOW ROLES extended options into delegate dispatch#168023

Merged
trunk-io[bot] merged 4 commits into
cockroachdb:masterfrom
souravcrl:show-roles-delegate
Apr 21, 2026
Merged

sql: wire SHOW ROLES extended options into delegate dispatch#168023
trunk-io[bot] merged 4 commits into
cockroachdb:masterfrom
souravcrl:show-roles-delegate

Conversation

@souravcrl
Copy link
Copy Markdown
Contributor

@souravcrl souravcrl commented Apr 9, 2026

Summary

  • Refactor delegateShowRolesExtended to accept (options *ShowUsersOptions, limit *Limit) parameters instead of *tree.ShowUsers, so it can serve both SHOW USERS and SHOW ROLES
  • Update the delegate dispatcher to pass ShowRoles.Options and ShowRoles.Limit through the extended path
  • Remove the TODO(sourav) comment since the function is now wired into both code paths
  • Update unit tests to match the new function signature

Part 2 of 3 — depends on #168022.

Informs: CRDB-62959
Epic: none

🤖 Generated with Claude Code

@souravcrl souravcrl requested a review from a team as a code owner April 9, 2026 11:11
@souravcrl souravcrl requested review from michae2 and removed request for a team April 9, 2026 11:11
@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io Bot commented Apr 9, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

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

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@yuzefovich yuzefovich requested review from a team and removed request for michae2 April 9, 2026 17:07
@souravcrl souravcrl force-pushed the show-roles-delegate branch 2 times, most recently from 457dd23 to 67411c8 Compare April 13, 2026 09:59
souravcrl and others added 4 commits April 20, 2026 14:22
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>
@souravcrl souravcrl force-pushed the show-roles-delegate branch from 67411c8 to bc5cc71 Compare April 20, 2026 10:18
@trunk-io trunk-io Bot merged commit bc5cc71 into cockroachdb:master Apr 21, 2026
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants