-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add 7 missing PostgreSQL catalog tables for protocol completeness #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Design document for implementing 7 missing pg_catalog tables: - pg_settings (dedicated handler, dynamic config) - pg_sequence (dedicated handler, maps sqlite_sequence) - pg_trigger (dedicated handler, maps SQLite triggers) - pg_collation (inline static) - pg_replication_slots (inline stub) - pg_shdepend (inline stub) - pg_statistic (inline stub) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Detailed bite-sized implementation plan with: - 8 tasks covering all 7 catalog tables - Integration tests for each table - Complete code samples - Step-by-step verification commands 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
The alerts_triggered counter was being incremented in both update_stats() and trigger_alert(), causing double-counting for high-severity events. Removed the duplicate increment from trigger_alert() since update_stats() already handles the counting. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements pg_collation catalog table with standard PostgreSQL collations (default, C, POSIX). Includes column projection support and WHERE clause filtering by collname. Changes: - Added handle_pg_collation_query() in query_interceptor.rs with full column projection support using extract_selected_columns() - Added extract_collation_name_filter() for WHERE collname filtering - Updated has_catalog_tables check to detect pg_collation queries - Added pg_collation handler in check_table_factor() - Added pg_collation handling in db_handler.rs query_with_session() and query_with_session_cached() for direct DbHandler access - Added integration test in tests/pg_collation_test.rs Test Results: - cargo test --test pg_collation_test: PASSED - cargo test --lib: 473 tests PASSED - cargo check: No errors - cargo clippy: No new warnings - cargo build: Successful 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements PostgreSQL pg_replication_slots view as an always-empty stub. SQLite has no replication capabilities, so this table correctly returns zero rows but with the proper schema for PostgreSQL compatibility. This enables tools that query pg_replication_slots (like pgAdmin, monitoring tools, and ORMs) to work without errors. Changes: - Added handle_pg_replication_slots_query to CatalogInterceptor - Added pg_replication_slots detection in has_catalog_tables check - Added handler routing in check_table_factor - Added direct handling in query_with_session and query_with_session_cached - Includes all 16 standard pg_replication_slots columns - Integration tests verify empty result with correct schema 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implements PostgreSQL pg_shdepend view as an always-empty stub. SQLite has no shared object dependencies, so this table correctly returns zero rows but with the proper schema for PostgreSQL compatibility. This enables tools that query pg_shdepend (like pgAdmin, monitoring tools, and ORMs) to work without errors. Changes: - Added handle_pg_shdepend_query to CatalogInterceptor - Added pg_shdepend detection in has_catalog_tables check - Added handler routing in check_table_factor - Added direct handling in query_with_session and query_with_session_cached - Includes all 7 standard pg_shdepend columns - Integration tests verify empty result with correct schema 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implemented pg_statistic support following the same pattern as pg_shdepend. This is an internal PostgreSQL statistics table - user-facing interface is the pg_stats view. Always returns empty results as SQLite doesn't maintain PostgreSQL-style column statistics internally. Implementation includes: - 31 columns: starelid, staattnum, stainherit, stanullfrac, stawidth, stadistinct, stakind1-5, staop1-5, stacoll1-5, stanumbers1-5, stavalues1-5 - Handler in query_interceptor.rs with column projection support - Fallback handlers in db_handler.rs for both query() and query_with_session() - Comprehensive integration tests verifying empty results and all columns 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implement dynamic pg_trigger handler that queries SQLite's sqlite_master for trigger information and maps it to PostgreSQL's pg_trigger schema. Key features: - Queries SQLite: SELECT name, tbl_name, sql FROM sqlite_master WHERE type = 'trigger' - Parses trigger SQL to extract timing (BEFORE/AFTER/INSTEAD OF) and event (INSERT/UPDATE/DELETE) - Calculates tgtype bitmask matching PostgreSQL conventions: - Bit 0: ROW (1) - SQLite triggers are always row-level - Bit 1: BEFORE (2) - Bit 6: INSTEAD OF (64) - Bits 2-4: INSERT (4), DELETE (8), UPDATE (16) - Generates OIDs for triggers and tables using hash functions - Supports WHERE clause filtering - Returns results sorted by trigger name Implementation: - Created src/catalog/pg_trigger.rs following pg_sequence.rs pattern - Reuses parse_trigger_sql() logic from information_schema.triggers - Integrated into query_interceptor.rs for routing pg_trigger queries - Added comprehensive test suite with 5 test cases Tests verify: - Basic trigger properties (name, tgrelid, tgtype, tgenabled) - BEFORE/AFTER timing detection - INSERT/UPDATE/DELETE event detection - Empty result sets when no triggers exist - Multiple triggers with proper sorting All tests passing (5/5). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Implemented pg_settings as a static handler returning PostgreSQL-like configuration settings. This table is heavily queried by PostgreSQL clients during connection setup, especially for SHOW commands. Features: - 41 common PostgreSQL settings (version, encoding, DateStyle, etc.) - Full 17-column schema (name, setting, unit, category, etc.) - WHERE clause filtering by name (critical for SHOW commands) - Static data - no SQLite interaction needed Implementation: - Created src/catalog/pg_settings.rs with PgSettingsHandler - Added to query interceptor and db_handler query routing - Includes comprehensive test suite with 4 test cases Test coverage: - Basic query returns 40+ settings - WHERE name filter works correctly - All columns return proper values - Common settings are present This completes Task 7 from the missing catalog tables implementation plan. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
These files were created but not committed in the original pg_sequence implementation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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
Adds 7 missing PostgreSQL catalog tables to improve protocol completeness:
sqlite_sequencetablesqlite_masterfor triggersArchitecture
New Files
src/catalog/pg_sequence.rs- Dynamic sequence handlersrc/catalog/pg_trigger.rs- Dynamic trigger handlersrc/catalog/pg_settings.rs- Static settings handlerTest Plan
cargo check- no errorscargo clippy- no new warningscargo build- successful🤖 Generated with Claude Code