| 1152 | } |
| 1153 | |
| 1154 | fn parse_sql<'b>(&self, sql: &'b str) -> Result<Vec<StatementParseResult<'b>>, ErrorResponse> { |
| 1155 | let parse_start = Instant::now(); |
| 1156 | let result = match self.adapter_client.parse(sql) { |
| 1157 | Ok(result) => result.map_err(|e| { |
| 1158 | // Convert our 0-based byte position to pgwire's 1-based character |
| 1159 | // position. |
| 1160 | let pos = sql[..e.error.pos].chars().count() + 1; |
| 1161 | ErrorResponse::error(SqlState::SYNTAX_ERROR, e.error.message).with_position(pos) |
| 1162 | }), |
| 1163 | Err(msg) => Err(ErrorResponse::error(SqlState::PROGRAM_LIMIT_EXCEEDED, msg)), |
| 1164 | }; |
| 1165 | self.adapter_client |
| 1166 | .inner() |
| 1167 | .metrics() |
| 1168 | .parse_seconds |
| 1169 | .observe(parse_start.elapsed().as_secs_f64()); |
| 1170 | result |
| 1171 | } |
| 1172 | |
| 1173 | /// Executes a "Simple Query", see |
| 1174 | /// <https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-SIMPLE-QUERY> |