Sans-I/O encoding: build PostgreSQL frontend (client → server) messages.
MessageBuilder accumulates a message body as a list[bytes]and joins it once on
getvalue — never += on bytes in a loop (the patitas stringbuilderidiom). The
build_*helpers wrap a body in the wire frame (1-byte tag + Int32 length). The startup
message is special-cased: it has no tag. This module touches no socket and no anyio.
data.drivers._pelt._builder
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
Accumulates a frontend message body, joined once ongetvalue().
Wrapbody in a tagged wire frame: tag + Int32(len(body) + 4) + body.
The untagged StartupMessage: protocol version +key\0value\0pairs + a final NUL.
A simple-protocolQuery (tag 'Q').
Extended-protocolParse (tag 'P'). param_oidsmay be empty (server infers).
Extended-protocolBind (tag 'B').
Parameters remain text encoded.result_formatsis empty for PostgreSQL's all-text default, one code for every result column, or a…
Extended-protocolDescribe (tag 'D'). kind is 'S'(statement) or
'P'(portal).
Extended-protocolExecute (tag 'E'). max_rows == 0means "all rows".
Extended-protocolSync (tag 'S').
Flush (tag 'H').
Extended-protocolClose (tag 'C'). kind is 'S'(statement) or
'P'(portal).
Terminate (tag 'X') — a graceful goodbye.
A cleartext/MD5PasswordMessage (tag 'p').
SASL initialPasswordMessage: mechanism cstring + Int32 length + payload.
SASL continuationPasswordMessage: raw mechanism response bytes only.
MessageBuilder
class
Accumulates a frontend message body, joined once ongetvalue().
frame
function
def frame(tag: bytes, body: bytes) -> bytes
Wrapbody in a tagged wire frame: tag + Int32(len(body) + 4) + body.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
tag
|
bytes
|
— | |
body
|
bytes
|
— |
build_startup
function
def build_startup(*, user: str, database: str = '', **params: str) -> bytes
The untagged StartupMessage: protocol version +key\0value\0pairs + a final NUL.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
user
|
str
|
— | |
database
|
str
|
''
|
|
**params
|
str
|
— |
build_query
function
def build_query(sql: str) -> bytes
A simple-protocolQuery (tag 'Q').
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
sql
|
str
|
— |
build_parse
function
def build_parse(*, name: str, query: str, param_oids: Sequence[int] = ()) -> bytes
Extended-protocolParse (tag 'P'). param_oidsmay be empty (server infers).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
name
|
str
|
— | |
query
|
str
|
— | |
param_oids
|
Sequence[int]
|
()
|
build_bind
function
def build_bind(*, portal: str = '', statement: str = '', params: Sequence[bytes | None] = (), result_formats: Sequence[int] = ()) -> bytes
Extended-protocolBind (tag 'B').
Parameters remain text encoded.result_formatsis empty for PostgreSQL's
all-text default, one code for every result column, or a one-code
all-columns shortcut. Codes are validated before framing so malformed
negotiation never reaches the socket.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
portal
|
str
|
''
|
|
statement
|
str
|
''
|
|
params
|
Sequence[bytes | None]
|
()
|
|
result_formats
|
Sequence[int]
|
()
|
build_describe
function
def build_describe(*, kind: str, name: str = '') -> bytes
Extended-protocolDescribe (tag 'D'). kind is 'S'(statement) or
'P'(portal).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
kind
|
str
|
— | |
name
|
str
|
''
|
build_execute
function
def build_execute(*, portal: str = '', max_rows: int = 0) -> bytes
Extended-protocolExecute (tag 'E'). max_rows == 0means "all rows".
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
portal
|
str
|
''
|
|
max_rows
|
int
|
0
|
build_sync
function
def build_sync() -> bytes
Extended-protocolSync (tag 'S').
No parameters.
build_flush
function
def build_flush() -> bytes
Flush (tag 'H').
No parameters.
build_close
function
def build_close(*, kind: str, name: str = '') -> bytes
Extended-protocolClose (tag 'C'). kind is 'S'(statement) or
'P'(portal).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
kind
|
str
|
— | |
name
|
str
|
''
|
build_terminate
function
def build_terminate() -> bytes
Terminate (tag 'X') — a graceful goodbye.
No parameters.
build_password
function
def build_password(password: bytes) -> bytes
A cleartext/MD5PasswordMessage (tag 'p').
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
password
|
bytes
|
— |
build_sasl_initial
function
def build_sasl_initial(*, mechanism: str, initial_response: bytes) -> bytes
SASL initialPasswordMessage: mechanism cstring + Int32 length + payload.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
mechanism
|
str
|
— | |
initial_response
|
bytes
|
— |
build_sasl_continue
function
def build_sasl_continue(response: bytes) -> bytes
SASL continuationPasswordMessage: raw mechanism response bytes only.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
response
|
bytes
|
— |
View source · /home/runner/work/chirp/chirp/site/../src/chirp/data/drivers/_pelt/_builder.py:1