feat(pgproto): implement protocol extension for query metadata
Summary
This MR adds two custom options to postgres protocol:
pico_query_metadata and pico_stmt_invalidation.
pico_query_metadata is a custom postgres protocol
option for getting query metadata. This information
allows smart clients to precalculate bucket id in order to reduce
the number of round trips between instances. This option
can be enabled through options parameter or startup params.
Currently, only single row inserts with bare params and params which are casted to the self type are supported. That is, queries such as:
-- CREATE TABLE t (a INT PRIMARY KEY, b DECIMAL, C DOUBLE)
INSERT INTO t VALUES ($1, $2, $3)
It's important to notice that casts are not allowed inside values unless its type matches parameter type.
For instance, for the above query metadata is following:
NOTICE:
{
"type": "PreparedStatementMetadata",
"query": "explain insert into t values ($1, $2, $3) ",
"tier": "default",
"dk_meta": [
[
1,
20
]
]
}
pico_stmt_invalidation is custom postgres protocol extension
which allows to get error when binding parameters to invalid
statement. The option can be set via psql or startup params.
See ADR to get more info https://git.picodata.io/core/picodata/-/blob/master/doc/adr/2025-09-12-pgproto-query-metadata.md