Skip to main content

agent_first_psql/
protocol.rs

1pub mod error_code {
2    pub const CANCELLED: &str = "cancelled";
3    pub const CONNECT_FAILED: &str = "connect_failed";
4    pub const INVALID_PARAMS: &str = "invalid_params";
5    pub const INVALID_REQUEST: &str = "invalid_request";
6    pub const RESULT_TOO_LARGE: &str = "result_too_large";
7}
8
9pub mod log_event {
10    pub const CONNECT_LIBPQ_ENV_FALLBACK: &str = "connect.libpq_env_fallback";
11    pub const MODE_PERMISSION_DEFAULT_CHANGED: &str = "mode.permission_default_changed";
12    pub const QUERY_ERROR: &str = "query.error";
13    pub const QUERY_RESULT: &str = "query.result";
14    pub const QUERY_SQL_ERROR: &str = "query.sql_error";
15    pub const STARTUP: &str = "startup";
16    pub const TRANSPORT_SELECTED: &str = "transport.selected";
17}
18
19pub mod command_tag {
20    pub const EXECUTE: &str = "EXECUTE";
21    pub const SELECT: &str = "SELECT";
22    pub const BEGIN: &str = "BEGIN";
23    pub const COMMIT: &str = "COMMIT";
24    pub const ROLLBACK: &str = "ROLLBACK";
25
26    pub fn execute(affected: usize) -> String {
27        format!("EXECUTE {affected}")
28    }
29
30    pub fn rows(row_count: usize) -> String {
31        format!("ROWS {row_count}")
32    }
33}
34
35// Log-filter matching lives in afdata's `LogFilters::enabled`; afpsql threads
36// the `LogFilters` type through its config instead of keeping a second matcher.