MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / insert

Method insert

src/expr-parser/src/catalog.rs:35–53  ·  view source on GitHub ↗

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,
        cols: Vec<String>,
        typ: SqlRelationType,
        transient: bool,
    )

Source from the content-addressed store, hash-verified

33 ///
34 /// Errors if an object of the same name is already in the catalog.
35 pub fn insert(
36 &mut self,
37 name: &str,
38 cols: Vec<String>,
39 typ: SqlRelationType,
40 transient: bool,
41 ) -> Result<GlobalId, String> {
42 if self.objects.contains_key(name) {
43 return Err(format!("Object {name} already exists in catalog"));
44 }
45 let id = if transient {
46 GlobalId::Transient(u64::cast_from(self.objects.len()))
47 } else {
48 GlobalId::User(u64::cast_from(self.objects.len()))
49 };
50 self.objects.insert(name.to_string(), (id, cols, typ));
51 self.names.insert(id, name.to_string());
52 Ok(id)
53 }
54
55 pub fn get(&'a self, name: &str) -> Option<&'a (GlobalId, Vec<String>, SqlRelationType)> {
56 self.objects.get(name)

Callers 2

handle_defineFunction · 0.45
fix_typesFunction · 0.45

Calls 4

contains_keyMethod · 0.80
UserClass · 0.50
lenMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected