Extract enhanced metadata including optimization information
(
&self,
stmt: &Statement,
query: &str,
_pattern: &QueryPattern,
hints: &OptimizationHints,
)
| 197 | |
| 198 | /// Extract enhanced metadata including optimization information |
| 199 | fn extract_enhanced_metadata( |
| 200 | &self, |
| 201 | stmt: &Statement, |
| 202 | query: &str, |
| 203 | _pattern: &QueryPattern, |
| 204 | hints: &OptimizationHints, |
| 205 | ) -> Result<StatementMetadata, rusqlite::Error> { |
| 206 | let columns = stmt.columns(); |
| 207 | let mut column_names = Vec::with_capacity(columns.len()); |
| 208 | let mut column_types = Vec::with_capacity(columns.len()); |
| 209 | |
| 210 | for column in columns { |
| 211 | let column_name = column.name().to_string(); |
| 212 | column_names.push(column_name.clone()); |
| 213 | |
| 214 | // Extract column type information from the column |
| 215 | let mut column_type = column.decl_type().map(|s| s.to_string()); |
| 216 | |
| 217 | // Special handling for PostgreSQL datetime functions |
| 218 | // If SQLite returns no type info but we know this is a datetime function, |
| 219 | // override with the correct PostgreSQL type |
| 220 | if column_type.is_none() && is_datetime_function_result(query, &column_name) { |
| 221 | column_type = Some("timestamptz".to_string()); |
| 222 | } |
| 223 | |
| 224 | column_types.push(column_type); |
| 225 | } |
| 226 | |
| 227 | let parameter_count = stmt.parameter_count(); |
| 228 | let is_select = query.trim().to_uppercase().starts_with("SELECT") || |
| 229 | query.trim().to_uppercase().starts_with("WITH"); |
| 230 | |
| 231 | Ok(StatementMetadata { |
| 232 | column_names, |
| 233 | column_types, |
| 234 | parameter_count, |
| 235 | is_select, |
| 236 | complexity: hints.complexity, |
| 237 | expected_result_size: hints.expected_result_size, |
| 238 | use_fast_path: hints.use_fast_path, |
| 239 | cache_results: hints.cache_result, |
| 240 | }) |
| 241 | } |
| 242 | |
| 243 | /// Extract basic metadata for non-cached queries |
| 244 | fn extract_basic_metadata(&self, stmt: &Statement, query: &str) -> Result<StatementMetadata, rusqlite::Error> { |
no test coverage detected