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

Function extract_table_name_from_update

src/query/executor.rs:2738–2760  ·  view source on GitHub ↗

Extract table name from UPDATE statement

(query: &str)

Source from the content-addressed store, hash-verified

2736
2737/// Extract table name from UPDATE statement
2738fn extract_table_name_from_update(query: &str) -> Option<String> {
2739 // Look for UPDATE pattern with case-insensitive search
2740 let update_pos = query.as_bytes().windows(6)
2741 .position(|window| window.eq_ignore_ascii_case(b"UPDATE"))?;
2742
2743 let after_update = &query[update_pos + 6..].trim();
2744
2745 // Find the end of table name (SET keyword)
2746 let table_end = after_update.find(|c: char| {
2747 c.is_whitespace() || c == ';'
2748 }).unwrap_or(after_update.len());
2749
2750 let table_name = after_update[..table_end].trim();
2751
2752 // Remove quotes if present
2753 let table_name = table_name.trim_matches('"').trim_matches('\'');
2754
2755 if !table_name.is_empty() {
2756 Some(table_name.to_string())
2757 } else {
2758 None
2759 }
2760}
2761
2762/// Extract table name from DELETE statement
2763fn extract_table_name_from_delete(query: &str) -> Option<String> {

Callers 3

execute_dmlMethod · 0.85
handle_executeMethod · 0.85

Calls 2

lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected