Commit 4416f36
sql: add e2e tests and fix privilege/NULL bugs for DROP PROVISIONED ROLES
Add comprehensive logic tests for DROP PROVISIONED ROLES and fix two
bugs:
1. Privilege escalation: the internal query used `params.p.User()`
which fails for non-admin CREATEROLE users who lack SELECT on
system.users. Switched to `NodeUserSessionDataOverride` since the
CREATEROLE authorization check already happened at plan time.
2. NULL filter panic: passing NULL as a SOURCE or LAST LOGIN BEFORE
filter expression caused a server panic via tree.MustBeDString /
tree.MustBeDTimestampTZ on tree.DNull. Added explicit DNull checks
after eval.Expr, returning a proper InvalidParameterValue error
instead of crashing the node. Follows the established pattern from
set_zone_config.go.
Refactors the main loop into two passes: the first pass filters
candidates by checking permissions and dependencies, accumulating
eligible users into a slice; the second pass performs the deletions.
Tests cover all existing behavior plus:
- NULL filter rejection for SOURCE and LAST LOGIN BEFORE
- Negative test: no dedicated `drop_provisioned_role` audit event
type (currently reuses generic `drop_role`)
- Session revocation: web sessions for dropped users are revoked
- EXPLAIN planning for various filter combinations
Fixes: #170030
Fixes: #170031
Fixes: #170032
Fixes: #170048
Informs: #170033
Epic: CRDB-54682
Release note: None
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 33d214c commit 4416f36
4 files changed
Lines changed: 1007 additions & 11 deletions
File tree
- pkg/sql
- logictest
- testdata/logic_test
- tests/local
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
132 | 137 | | |
133 | 138 | | |
134 | 139 | | |
135 | 140 | | |
136 | | - | |
| 141 | + | |
137 | 142 | | |
138 | 143 | | |
139 | 144 | | |
| |||
149 | 154 | | |
150 | 155 | | |
151 | 156 | | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
156 | 162 | | |
157 | 163 | | |
158 | 164 | | |
| |||
179 | 185 | | |
180 | 186 | | |
181 | 187 | | |
182 | | - | |
183 | 188 | | |
184 | 189 | | |
185 | 190 | | |
| |||
195 | 200 | | |
196 | 201 | | |
197 | 202 | | |
198 | | - | |
199 | 203 | | |
200 | 204 | | |
201 | 205 | | |
202 | | - | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
203 | 213 | | |
204 | 214 | | |
205 | 215 | | |
206 | 216 | | |
207 | 217 | | |
208 | | - | |
209 | 218 | | |
210 | 219 | | |
211 | 220 | | |
212 | 221 | | |
213 | | - | |
| 222 | + | |
214 | 223 | | |
215 | 224 | | |
216 | 225 | | |
| |||
252 | 261 | | |
253 | 262 | | |
254 | 263 | | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
255 | 268 | | |
256 | 269 | | |
257 | 270 | | |
| |||
260 | 273 | | |
261 | 274 | | |
262 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
263 | 280 | | |
264 | 281 | | |
265 | 282 | | |
| |||
0 commit comments