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

Method extract_table_name

src/optimization/read_only_optimizer.rs:413–437  ·  view source on GitHub ↗

Extract table name from SELECT query

(&self, query: &str)

Source from the content-addressed store, hash-verified

411
412 /// Extract table name from SELECT query
413 fn extract_table_name(&self, query: &str) -> Option<String> {
414 let query_upper = query.to_uppercase();
415
416 // Find FROM clause
417 if let Some(from_pos) = query_upper.find(" FROM ") {
418 let after_from = &query[from_pos + 6..].trim();
419
420 // Find end of table name
421 let end = after_from.find(' ')
422 .or_else(|| after_from.find(';'))
423 .or_else(|| after_from.find('\n'))
424 .unwrap_or(after_from.len());
425
426 let table_name = after_from[..end].trim();
427
428 // Remove quotes if present
429 let table_name = table_name.trim_matches('"').trim_matches('\'');
430
431 if !table_name.is_empty() {
432 return Some(table_name.to_string());
433 }
434 }
435
436 None
437 }
438
439 /// Classify query complexity for optimization decisions
440 fn classify_query_complexity(&self, query: &str) -> QueryComplexity {

Callers 1

Calls 2

lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected