feat: implement PostgreSQL extended query protocol (Parse/Bind/Execute/Sync)#1141
Open
SBALAVIGNESH123 wants to merge 4 commits intotimeplus-io:developfrom
Open
Conversation
…tore When seek_to uses a relative or absolute time (e.g. '-15m') with enable_backfill_from_historical_store enabled, the query enters StreamingConcat mode which scans all historical MergeTree parts before streaming begins, causing the query to appear hung. This fix probes NativeLog first: if the streaming store still has the requested data, convert the time-based seek to a sequence-based seek and use QueryMode::Streaming, bypassing the expensive historical scan entirely. Falls back to existing StreamingConcat when the data has been compacted. Fixes timeplus-io#558
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
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.
This PR adds support for the PostgreSQL extended query protocol, which is needed for tools like DBeaver and pgAdmin to connect to Proton. Currently, the handler rejects all extended query messages (Parse, Bind, Describe, Execute, Sync, Close, Flush) with an error saying "proton doesn't support extended query mechanism". This means most modern PostgreSQL drivers and GUI tools fail on connect since they default to the extended query protocol for prepared statements and parameter binding.
The approach here is server-side parameter substitution — the client sends Parse/Bind with $1, $2 placeholders and parameter values, and we substitute them into the SQL before passing it to Proton's existing query engine. This way we get full client compatibility without any changes to the parser or interpreter. A new PreparedStatementManager handles the lifecycle of named and unnamed statements and portals.I also added interception for the various system queries that PG clients send on connect (pg_catalog, SET, SHOW server_version, SELECT version(), SELECT current_schema(), transaction commands, etc.) so that clients don't crash when they can't find system tables. The type mapping was expanded to cover Bool, DateTime, DateTime64, Enum, Map, Array, and large integer types.The parameter substitution is string-literal-aware (won't replace $1 inside single quotes) and escapes single quotes and backslashes to prevent SQL injection. Error handling follows the PG spec — after an error during extended query, all subsequent messages are skipped until a Sync message resets the pipeline.
"This is intentionally a compatibility layer — same approach CockroachDB used in their early PG wire support. Server-side substitution gives us 95% client compatibility with zero query engine changes. True prepared execution is a future enhancement."
Closes #225