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

Function process_query

src/query/query_processor.rs:17–65  ·  view source on GitHub ↗
(
    query: &str,
    conn: &Connection,
    schema_cache: &SchemaCache,
)

Source from the content-addressed store, hash-verified

15/// Process a query, using fast path when possible
16#[inline(always)]
17pub fn process_query(
18 query: &str,
19 conn: &Connection,
20 schema_cache: &SchemaCache,
21) -> Result<String, rusqlite::Error> {
22 // Handle CREATE TABLE statements first - they need special translation regardless of processor type
23 if query.trim_start().to_uppercase().starts_with("CREATE TABLE") {
24 use crate::translator::CreateTableTranslator;
25 match CreateTableTranslator::translate_with_connection(query, Some(conn)) {
26 Ok((translated, _type_mappings)) => {
27 debug!("CREATE TABLE translated in process_query: {}", translated);
28 return Ok(translated);
29 }
30 Err(e) => {
31 tracing::warn!("Failed to translate CREATE TABLE in process_query: {}", e);
32 // Fall through to normal processing
33 }
34 }
35 }
36 #[cfg(feature = "unified_processor")]
37 {
38 // New unified processor - returns Cow to avoid allocations
39 match unified_processor::process_query(query, conn, schema_cache) {
40 Ok(cow) => {
41 let is_borrowed = matches!(&cow, std::borrow::Cow::Borrowed(_));
42 if is_borrowed {
43 debug!("Using UNIFIED FAST PATH (zero-alloc) for query: {}", query);
44 } else {
45 debug!("Using UNIFIED PROCESSOR (with translation) for query: {}", query);
46 }
47 Ok(cow.into_owned())
48 }
49 Err(e) => Err(e),
50 }
51 }
52
53 #[cfg(not(feature = "unified_processor"))]
54 {
55 // Old implementation - kept for A/B testing
56 if is_fast_path_simple_query(query) {
57 debug!("Using OLD FAST PATH for query: {}", query);
58 return Ok(query.to_string());
59 }
60
61 debug!("Using OLD SLOW PATH (LazyQueryProcessor) for query: {}", query);
62 let mut processor = LazyQueryProcessor::new(query);
63 Ok(processor.process(conn, schema_cache)?.to_string())
64 }
65}

Callers 8

handle_parseMethod · 0.70
execute_with_paramsMethod · 0.50
queryMethod · 0.50
query_with_sessionMethod · 0.50
executeMethod · 0.50
execute_with_sessionMethod · 0.50

Calls 2

processMethod · 0.80

Tested by

no test coverage detected