Execute a SQL query: session state → identity → DDL check → quota → plan → perms → dispatch. Handles multi-statement queries (e.g. psql heredoc sends all statements in one message). Splits at top-level semicolons before dispatching so that `parts[2]` is never polluted with trailing `;` characters.
(
&self,
identity: &AuthenticatedIdentity,
addr: &std::net::SocketAddr,
sql: &str,
)
| 26 | /// Splits at top-level semicolons before dispatching so that `parts[2]` is never polluted |
| 27 | /// with trailing `;` characters. |
| 28 | pub(super) async fn execute_sql( |
| 29 | &self, |
| 30 | identity: &AuthenticatedIdentity, |
| 31 | addr: &std::net::SocketAddr, |
| 32 | sql: &str, |
| 33 | ) -> PgWireResult<Vec<Response>> { |
| 34 | let statements = split_sql_statements(sql); |
| 35 | match statements.len() { |
| 36 | 0 => Ok(vec![Response::EmptyQuery]), |
| 37 | 1 => { |
| 38 | self.execute_single_sql(identity, addr, &statements[0]) |
| 39 | .await |
| 40 | } |
| 41 | _ => { |
| 42 | let mut all = Vec::new(); |
| 43 | for stmt in statements { |
| 44 | let mut resp = self.execute_single_sql(identity, addr, &stmt).await?; |
| 45 | all.append(&mut resp); |
| 46 | } |
| 47 | Ok(all) |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /// Execute a single (already-split) SQL statement. |
| 53 | async fn execute_single_sql( |
no test coverage detected