| 9 | |
| 10 | impl PgClassHandler { |
| 11 | pub async fn handle_query( |
| 12 | select: &Select, |
| 13 | db: &DbHandler, |
| 14 | ) -> Result<DbResponse, PgSqliteError> { |
| 15 | debug!("Handling pg_class query"); |
| 16 | |
| 17 | // Get list of tables from SQLite |
| 18 | let tables_response = db.query("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '__pgsqlite_%'").await?; |
| 19 | |
| 20 | // Define all available columns - PostgreSQL has 33 columns in pg_class |
| 21 | let all_columns = vec![ |
| 22 | "oid".to_string(), |
| 23 | "relname".to_string(), |
| 24 | "relnamespace".to_string(), |
| 25 | "reltype".to_string(), |
| 26 | "reloftype".to_string(), |
| 27 | "relowner".to_string(), |
| 28 | "relam".to_string(), |
| 29 | "relfilenode".to_string(), |
| 30 | "reltablespace".to_string(), |
| 31 | "relpages".to_string(), |
| 32 | "reltuples".to_string(), |
| 33 | "relallvisible".to_string(), |
| 34 | "reltoastrelid".to_string(), |
| 35 | "relhasindex".to_string(), |
| 36 | "relisshared".to_string(), |
| 37 | "relpersistence".to_string(), |
| 38 | "relkind".to_string(), |
| 39 | "relnatts".to_string(), |
| 40 | "relchecks".to_string(), |
| 41 | "relhasrules".to_string(), |
| 42 | "relhastriggers".to_string(), |
| 43 | "relhassubclass".to_string(), |
| 44 | "relrowsecurity".to_string(), |
| 45 | "relforcerowsecurity".to_string(), |
| 46 | "relispopulated".to_string(), |
| 47 | "relreplident".to_string(), |
| 48 | "relispartition".to_string(), |
| 49 | "relrewrite".to_string(), |
| 50 | "relfrozenxid".to_string(), |
| 51 | "relminmxid".to_string(), |
| 52 | "relacl".to_string(), |
| 53 | "reloptions".to_string(), |
| 54 | "relpartbound".to_string(), |
| 55 | ]; |
| 56 | |
| 57 | // Determine which columns to return based on projection |
| 58 | let (columns, column_indices) = Self::get_projected_columns(select, &all_columns); |
| 59 | |
| 60 | // Create column mapping for WHERE evaluation (uses all columns) |
| 61 | let column_mapping: HashMap<String, usize> = all_columns |
| 62 | .iter() |
| 63 | .enumerate() |
| 64 | .map(|(i, name)| (name.clone(), i)) |
| 65 | .collect(); |
| 66 | |
| 67 | let mut rows = Vec::new(); |
| 68 | |