Extract table name from UPDATE statement
(query: &str)
| 2736 | |
| 2737 | /// Extract table name from UPDATE statement |
| 2738 | fn 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 |
| 2763 | fn extract_table_name_from_delete(query: &str) -> Option<String> { |
no test coverage detected