Skip to content

Implement CONTEXT_INFO and SESSION_CONTEXT features - #27

Open
celsowm wants to merge 1 commit into
mainfrom
feat/session-context-info-7295642607711709711
Open

Implement CONTEXT_INFO and SESSION_CONTEXT features#27
celsowm wants to merge 1 commit into
mainfrom
feat/session-context-info-7295642607711709711

Conversation

@celsowm

@celsowm celsowm commented Apr 16, 2026

Copy link
Copy Markdown
Owner

I have implemented a set of features related to session state management, bringing Iridium SQL closer to 1:1 compatibility with SQL Server. Specifically, I added support for CONTEXT_INFO and SESSION_CONTEXT.

Features Implemented:

  1. SET CONTEXT_INFO Statement: Users can now set a 128-byte binary context for their session using literals (e.g., SET CONTEXT_INFO 0xABCD) or variables.
  2. CONTEXT_INFO() Function: A new scalar function to retrieve the current session's context info.
  3. SESSION_CONTEXT Key-Value Store: Implemented the SQL Server 2016+ session context feature.
    • sp_set_session_context: A system stored procedure to set key-value pairs, with support for the @read_only flag.
    • SESSION_CONTEXT(key): A scalar function to retrieve values by key.
  4. sys.dm_exec_sessions Integration: Added the context_info column to this DMV, enabling introspection of session context.
  5. Robustness: The session state is properly integrated into the engine's snapshotting mechanism, ensuring consistency across savepoints and transaction rollbacks.

Verification:

  • Added a new integration test file crates/iridium_core/tests/session_context_test.rs covering all new features and edge cases (e.g., read-only context keys).
  • Ran the full iridium_core test suite (~1300+ tests) to ensure no regressions were introduced.
  • The implementation follows the existing architectural patterns for parsing, AST lowering, and execution.

PR created automatically by Jules for task 7295642607711709711 started by @celsowm

This commit adds support for session-level state management in Iridium SQL,
matching SQL Server functionality for CONTEXT_INFO and SESSION_CONTEXT.

Key changes:
- Extended SessionRuntime and related structs to store context_info (128-byte binary)
  and session_context (key-value store with read-only support).
- Added SET CONTEXT_INFO statement support to the parser and executor.
- Implemented CONTEXT_INFO() and SESSION_CONTEXT(key) scalar functions.
- Implemented sp_set_session_context system stored procedure.
- Added context_info column to sys.dm_exec_sessions system view.
- Added Value::to_bool() helper for T-SQL truthiness evaluation.
- Included comprehensive tests in crates/iridium_core/tests/session_context_test.rs.

Co-authored-by: celsowm <369336+celsowm@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant