MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / query_message

Function query_message

nodedb/tests/pgwire_tls_e2e.rs:145–156  ·  view source on GitHub ↗

Build a pgwire simple Query message.

(sql: &str)

Source from the content-addressed store, hash-verified

143
144/// Build a pgwire simple Query message.
145fn query_message(sql: &str) -> Vec<u8> {
146 let body = {
147 let mut b = sql.as_bytes().to_vec();
148 b.push(0); // null terminator
149 b
150 };
151 let msg_len = (4u32 + body.len() as u32).to_be_bytes();
152 let mut msg = vec![b'Q'];
153 msg.extend_from_slice(&msg_len);
154 msg.extend_from_slice(&body);
155 msg
156}
157
158/// Read a single pgwire message from the stream.
159/// Returns `(type_byte, payload)` where payload excludes the 4-byte length field.

Callers 1

Calls 4

to_vecMethod · 0.45
as_bytesMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected