@@ -85,9 +85,7 @@ use uuid::Uuid;
8585
8686// DO NOT add any more imports from `crate` outside of `crate::catalog`.
8787pub use crate :: catalog:: builtin_table_updates:: BuiltinTableUpdate ;
88- pub use crate :: catalog:: open:: {
89- BuiltinMigrationMetadata , InitializeStateResult , OpenCatalogResult ,
90- } ;
88+ pub use crate :: catalog:: open:: { InitializeStateResult , OpenCatalogResult } ;
9189pub use crate :: catalog:: state:: CatalogState ;
9290pub use crate :: catalog:: transact:: {
9391 DropObjectInfo , Op , ReplicaCreateDropReason , TransactionResult ,
@@ -671,9 +669,9 @@ impl Catalog {
671669 // debugging/testing.
672670 let previous_ts = now ( ) . into ( ) ;
673671 let replica_size = & bootstrap_args. default_cluster_replica_size ;
672+ let read_only = false ;
674673 let OpenCatalogResult {
675674 catalog,
676- storage_collections_to_drop : _,
677675 migrated_storage_collections_0dt : _,
678676 new_builtin_collections : _,
679677 builtin_table_updates : _,
@@ -687,7 +685,7 @@ impl Catalog {
687685 all_features : false ,
688686 build_info : & DUMMY_BUILD_INFO ,
689687 environment_id : environment_id. unwrap_or ( EnvironmentId :: for_tests ( ) ) ,
690- read_only : false ,
688+ read_only,
691689 now,
692690 boot_ts : previous_ts,
693691 skip_migrations : true ,
@@ -705,7 +703,10 @@ impl Catalog {
705703 aws_privatelink_availability_zones : None ,
706704 http_host_name : None ,
707705 connection_context : ConnectionContext :: for_tests ( secrets_reader) ,
708- builtin_item_migration_config : BuiltinItemMigrationConfig :: Legacy ,
706+ builtin_item_migration_config : BuiltinItemMigrationConfig {
707+ persist_client : persist_client. clone ( ) ,
708+ read_only,
709+ } ,
709710 persist_client,
710711 enable_expression_cache_override,
711712 enable_0dt_deployment : true ,
@@ -3507,119 +3508,6 @@ mod tests {
35073508 . await
35083509 }
35093510
3510- #[ mz_ore:: test( tokio:: test) ]
3511- #[ cfg_attr( miri, ignore) ] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
3512- async fn test_builtin_migrations ( ) {
3513- let persist_client = PersistClient :: new_for_tests ( ) . await ;
3514- let bootstrap_args = test_bootstrap_args ( ) ;
3515- let organization_id = Uuid :: new_v4 ( ) ;
3516- let mv_name = "mv" ;
3517- let ( mz_tables_id, mv_id) = {
3518- let mut catalog = Catalog :: open_debug_catalog (
3519- persist_client. clone ( ) ,
3520- organization_id. clone ( ) ,
3521- & bootstrap_args,
3522- )
3523- . await
3524- . expect ( "unable to open debug catalog" ) ;
3525-
3526- // Create a materialized view over `mz_tables`.
3527- let database_id = DatabaseId :: User ( 1 ) ;
3528- let database = catalog. get_database ( & database_id) ;
3529- let database_name = database. name ( ) ;
3530- let schemas = database. schemas ( ) ;
3531- let schema = schemas. first ( ) . expect ( "must have at least one schema" ) ;
3532- let schema_spec = schema. id ( ) . clone ( ) ;
3533- let schema_name = & schema. name ( ) . schema ;
3534- let database_spec = ResolvedDatabaseSpecifier :: Id ( database_id) ;
3535- let id_ts = catalog. storage ( ) . await . current_upper ( ) . await ;
3536- let ( mv_id, mv_gid) = catalog
3537- . allocate_user_id ( id_ts)
3538- . await
3539- . expect ( "unable to allocate id" ) ;
3540- let mv = catalog
3541- . state ( )
3542- . deserialize_item (
3543- mv_gid,
3544- & format ! ( "CREATE MATERIALIZED VIEW {database_name}.{schema_name}.{mv_name} AS SELECT name FROM mz_tables" ) ,
3545- & BTreeMap :: new ( ) ,
3546- & mut LocalExpressionCache :: Closed ,
3547- None ,
3548- )
3549- . expect ( "unable to deserialize item" ) ;
3550- let commit_ts = catalog. current_upper ( ) . await ;
3551- catalog
3552- . transact (
3553- None ,
3554- commit_ts,
3555- None ,
3556- vec ! [ Op :: CreateItem {
3557- id: mv_id,
3558- name: QualifiedItemName {
3559- qualifiers: ItemQualifiers {
3560- database_spec,
3561- schema_spec,
3562- } ,
3563- item: mv_name. to_string( ) ,
3564- } ,
3565- item: mv,
3566- owner_id: MZ_SYSTEM_ROLE_ID ,
3567- } ] ,
3568- )
3569- . await
3570- . expect ( "unable to transact" ) ;
3571-
3572- let mz_tables_id = catalog
3573- . entries ( )
3574- . find ( |entry| & entry. name . item == "mz_tables" && entry. is_table ( ) )
3575- . expect ( "mz_tables doesn't exist" )
3576- . id ( ) ;
3577- let check_mv_id = catalog
3578- . entries ( )
3579- . find ( |entry| & entry. name . item == mv_name && entry. is_materialized_view ( ) )
3580- . unwrap_or_else ( || panic ! ( "{mv_name} doesn't exist" ) )
3581- . id ( ) ;
3582- assert_eq ! ( check_mv_id, mv_id) ;
3583- catalog. expire ( ) . await ;
3584- ( mz_tables_id, mv_id)
3585- } ;
3586- // Forcibly migrate all tables.
3587- {
3588- let mut guard =
3589- UNSAFE_DO_NOT_CALL_THIS_IN_PRODUCTION_BUILTIN_TABLE_FINGERPRINT_WHITESPACE
3590- . lock ( )
3591- . expect ( "lock poisoned" ) ;
3592- * guard = Some ( (
3593- UnsafeBuiltinTableFingerprintWhitespace :: All ,
3594- "\n " . to_string ( ) ,
3595- ) ) ;
3596- }
3597- {
3598- let catalog =
3599- Catalog :: open_debug_catalog ( persist_client, organization_id, & bootstrap_args)
3600- . await
3601- . expect ( "unable to open debug catalog" ) ;
3602-
3603- let new_mz_tables_id = catalog
3604- . entries ( )
3605- . find ( |entry| & entry. name . item == "mz_tables" && entry. is_table ( ) )
3606- . expect ( "mz_tables doesn't exist" )
3607- . id ( ) ;
3608- // Assert that the table was migrated and got a new ID.
3609- assert_ne ! ( new_mz_tables_id, mz_tables_id) ;
3610-
3611- let new_mv_id = catalog
3612- . entries ( )
3613- . find ( |entry| & entry. name . item == mv_name && entry. is_materialized_view ( ) )
3614- . unwrap_or_else ( || panic ! ( "{mv_name} doesn't exist" ) )
3615- . id ( ) ;
3616- // Assert that the materialized view was migrated and got a new ID.
3617- assert_ne ! ( new_mv_id, mv_id) ;
3618-
3619- catalog. expire ( ) . await ;
3620- }
3621- }
3622-
36233511 #[ mz_ore:: test( tokio:: test) ]
36243512 #[ cfg_attr( miri, ignore) ] // unsupported operation: can't call foreign function `TLS_client_method` on OS `linux`
36253513 async fn test_multi_subscriber_catalog ( ) {
0 commit comments