MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_sql

Method parse_sql

src/pgwire/src/protocol.rs:1154–1171  ·  view source on GitHub ↗
(&self, sql: &'b str)

Source from the content-addressed store, hash-verified

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>

Callers 2

queryMethod · 0.80
parseMethod · 0.80

Calls 8

nowFunction · 0.85
errorFunction · 0.85
with_positionMethod · 0.80
parseMethod · 0.45
countMethod · 0.45
observeMethod · 0.45
metricsMethod · 0.45
innerMethod · 0.45

Tested by

no test coverage detected