Registers an object in the catalog. Specifying `transient` as true allows the object to be deleted by [Self::remove_transient_objects]. Returns the GlobalId assigned by the catalog to the object. Errors if an object of the same name is already in the catalog.
(
&mut self,
name: &str,
typ: SqlRelationType,
transient: bool,
)
| 108 | /// |
| 109 | /// Errors if an object of the same name is already in the catalog. |
| 110 | pub fn insert( |
| 111 | &mut self, |
| 112 | name: &str, |
| 113 | typ: SqlRelationType, |
| 114 | transient: bool, |
| 115 | ) -> Result<GlobalId, String> { |
| 116 | if self.objects.contains_key(name) { |
| 117 | return Err(format!("Object {} already exists in catalog", name)); |
| 118 | } |
| 119 | let id = if transient { |
| 120 | GlobalId::Transient(u64::cast_from(self.objects.len())) |
| 121 | } else { |
| 122 | GlobalId::User(u64::cast_from(self.objects.len())) |
| 123 | }; |
| 124 | self.objects.insert(name.to_string(), (id, typ)); |
| 125 | self.names.insert(id, name.to_string()); |
| 126 | Ok(id) |
| 127 | } |
| 128 | |
| 129 | fn get(&'a self, name: &str) -> Option<&'a (GlobalId, SqlRelationType)> { |
| 130 | self.objects.get(name) |