Build a pgwire simple Query message.
(sql: &str)
| 143 | |
| 144 | /// Build a pgwire simple Query message. |
| 145 | fn 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. |
no test coverage detected