924060929 opened a new pull request, #64569:
URL: https://github.com/apache/doris/pull/64569
### What problem does this PR solve?
Problem Summary:
Session variables changed by a per-query `SET_VAR` hint (e.g.
`SELECT /*+ SET_VAR(session_context="trace_id:xxx") */ ...`) are temporary:
they are
reverted in the `finally` block of `StmtExecutor.execute()`. The audit log
is built
afterwards in `ConnectProcessor.auditAfterExec()`, which calls
`VariableMgr.dumpChangedVars()`
on the already-reverted session variables. As a result, the audit log
`changed_variables`
column never reflects variables set by a per-query `SET_VAR` hint — such a
variable always
shows up as missing there, while the same variable set at session level via
`SET ...` is
recorded correctly.
This PR snapshots the changed session variables in `StmtExecutor.execute()`
right before the
revert (only when a `SET_VAR` hint was used), and makes `AuditLogHelper`
prefer that snapshot,
so the audit log reflects the variables that were actually in effect for the
statement.
### Release note
Fix audit log `changed_variables` not recording session variables set by a
per-query `SET_VAR` hint.
### Check List (For Author)
- Test
- [x] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test.
- Behavior changed:
- [x] Yes. The audit log `changed_variables` now includes session
variables set by a per-query `SET_VAR` hint (previously they were missing).
- Does this need documentation?
- [x] No.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]