MCPcopy Create free account
hub / github.com/erans/pgsqlite / extract_metadata

Method extract_metadata

src/cache/statement_pool.rs:192–213  ·  view source on GitHub ↗

Extract metadata from a prepared statement

(&self, stmt: &Statement, query: &str)

Source from the content-addressed store, hash-verified

190
191 /// Extract metadata from a prepared statement
192 fn extract_metadata(&self, stmt: &Statement, query: &str) -> Result<StatementMetadata, rusqlite::Error> {
193 let column_count = stmt.column_count();
194 let mut column_names = Vec::new();
195 let mut column_types = Vec::new();
196
197 for i in 0..column_count {
198 column_names.push(sanitize_column_name(stmt.column_name(i)?).to_string());
199 // We can't easily get PostgreSQL types here, so we'll leave them as None
200 // They can be filled in later by the caller if needed
201 column_types.push(None);
202 }
203
204 let parameter_count = stmt.parameter_count();
205 let is_select = query.trim().to_uppercase().starts_with("SELECT");
206
207 Ok(StatementMetadata {
208 column_names,
209 column_types,
210 parameter_count,
211 is_select,
212 })
213 }
214
215 /// Evict the oldest entry from the cache
216 fn evict_oldest(&self, statements: &mut HashMap<String, CachedStatement>) {

Callers 1

prepare_and_cacheMethod · 0.80

Calls 1

sanitize_column_nameFunction · 0.85

Tested by

no test coverage detected