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

Function initialize

src/catalog/src/durable/initialize.rs:215–774  ·  view source on GitHub ↗
(
    tx: &mut Transaction<'_>,
    options: &BootstrapArgs,
    initial_ts: EpochMillis,
    catalog_content_version: String,
)

Source from the content-addressed store, hash-verified

213/// Initializes the Catalog with some default objects.
214#[mz_ore::instrument]
215pub(crate) async fn initialize(
216 tx: &mut Transaction<'_>,
217 options: &BootstrapArgs,
218 initial_ts: EpochMillis,
219 catalog_content_version: String,
220) -> Result<(), CatalogError> {
221 // Collect audit events so we can commit them once at the very end.
222 let mut audit_events = vec![];
223
224 for (name, next_id) in [
225 (USER_ID_ALLOC_KEY.to_string(), DEFAULT_ALLOCATOR_ID),
226 (SYSTEM_ID_ALLOC_KEY.to_string(), DEFAULT_ALLOCATOR_ID),
227 (
228 DATABASE_ID_ALLOC_KEY.to_string(),
229 MATERIALIZE_DATABASE_ID_VAL + 1,
230 ),
231 (
232 SCHEMA_ID_ALLOC_KEY.to_string(),
233 max(&[
234 MZ_CATALOG_SCHEMA_ID,
235 PG_CATALOG_SCHEMA_ID,
236 PUBLIC_SCHEMA_ID,
237 MZ_INTERNAL_SCHEMA_ID,
238 INFORMATION_SCHEMA_ID,
239 MZ_UNSAFE_SCHEMA_ID,
240 MZ_CATALOG_UNSTABLE_SCHEMA_ID,
241 MZ_INTROSPECTION_SCHEMA_ID,
242 ])
243 .expect("known to be non-empty")
244 + 1,
245 ),
246 (USER_ROLE_ID_ALLOC_KEY.to_string(), DEFAULT_ALLOCATOR_ID),
247 (
248 USER_CLUSTER_ID_ALLOC_KEY.to_string(),
249 DEFAULT_USER_CLUSTER_ID.inner_id() + 1,
250 ),
251 (
252 SYSTEM_CLUSTER_ID_ALLOC_KEY.to_string(),
253 DEFAULT_ALLOCATOR_ID,
254 ),
255 (
256 USER_REPLICA_ID_ALLOC_KEY.to_string(),
257 DEFAULT_USER_REPLICA_ID.inner_id()
258 + u64::from(options.default_cluster_replication_factor),
259 ),
260 (
261 SYSTEM_REPLICA_ID_ALLOC_KEY.to_string(),
262 DEFAULT_ALLOCATOR_ID,
263 ),
264 (
265 USER_NETWORK_POLICY_ID_ALLOC_KEY.to_string(),
266 DEFAULT_ALLOCATOR_ID,
267 ),
268 (AUDIT_LOG_ID_ALLOC_KEY.to_string(), DEFAULT_ALLOCATOR_ID),
269 (STORAGE_USAGE_ID_ALLOC_KEY.to_string(), DEFAULT_ALLOCATOR_ID),
270 (OID_ALLOC_KEY.to_string(), FIRST_USER_OID.into()),
271 ] {
272 tx.insert_id_allocator(name, next_id)?;

Callers 1

open_innerMethod · 0.70

Calls 15

all_object_privilegesFunction · 0.85
IdEnum · 0.85
PolicyAddressClass · 0.85
default_cluster_configFunction · 0.85
default_replica_configFunction · 0.85
expectMethod · 0.80
insert_id_allocatorMethod · 0.80
insert_builtin_roleMethod · 0.80
insert_user_roleMethod · 0.80
to_vecMethod · 0.80
insert_databaseMethod · 0.80

Tested by

no test coverage detected