chore: delete ns postgres impl, test improvements, fix to mem impl
parent
3659be59c7
commit
6263ca234a
|
@ -0,0 +1,48 @@
|
|||
ALTER TABLE parquet_file
|
||||
DROP CONSTRAINT parquet_file_namespace_id_fkey;
|
||||
ALTER TABLE parquet_file
|
||||
ADD CONSTRAINT parquet_file_namespace_id_fkey
|
||||
FOREIGN KEY (namespace_id) REFERENCES namespace(id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE processed_tombstone
|
||||
DROP CONSTRAINT processed_tombstone_parquet_file_id_fkey;
|
||||
ALTER TABLE processed_tombstone
|
||||
ADD CONSTRAINT processed_tombstone_parquet_file_id_fkey
|
||||
FOREIGN KEY (parquet_file_id) REFERENCES parquet_file(id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE tombstone
|
||||
DROP CONSTRAINT tombstone_table_id_fkey;
|
||||
ALTER TABLE tombstone
|
||||
ADD CONSTRAINT tombstone_table_id_fkey
|
||||
FOREIGN KEY (table_id) REFERENCES table_name(id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE table_name
|
||||
DROP CONSTRAINT table_name_namespace_id_fkey;
|
||||
ALTER TABLE table_name
|
||||
ADD CONSTRAINT table_name_namespace_id_fkey
|
||||
FOREIGN KEY (namespace_id) REFERENCES namespace(id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE column_name
|
||||
DROP CONSTRAINT column_name_table_id_fkey;
|
||||
ALTER TABLE column_name
|
||||
ADD CONSTRAINT column_name_table_id_fkey
|
||||
FOREIGN KEY (table_id) REFERENCES table_name(id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE partition
|
||||
DROP CONSTRAINT partition_table_id_fkey;
|
||||
ALTER TABLE partition
|
||||
ADD CONSTRAINT partition_table_id_fkey
|
||||
FOREIGN KEY (table_id) REFERENCES table_name(id)
|
||||
ON DELETE CASCADE;
|
||||
|
||||
ALTER TABLE billing_summary
|
||||
DROP CONSTRAINT billing_summary_namespace_id_fkey;
|
||||
ALTER TABLE billing_summary
|
||||
ADD CONSTRAINT billing_summary_namespace_id_fkey
|
||||
FOREIGN KEY (namespace_id) REFERENCES namespace(id)
|
||||
ON DELETE CASCADE;
|
|
@ -129,6 +129,9 @@ pub enum Error {
|
|||
|
||||
#[snafu(display("could not delete skipped compactions: {source}"))]
|
||||
CouldNotDeleteSkippedCompactions { source: sqlx::Error },
|
||||
|
||||
#[snafu(display("could not delete namespace: {source}"))]
|
||||
CouldNotDeleteNamespace { source: sqlx::Error },
|
||||
}
|
||||
|
||||
/// A specialized `Error` for Catalog errors
|
||||
|
@ -4487,6 +4490,12 @@ pub(crate) mod test_helpers {
|
|||
.len(),
|
||||
0
|
||||
);
|
||||
assert!(repos
|
||||
.partitions()
|
||||
.get_by_id(partition_1.id)
|
||||
.await
|
||||
.expect("fetching partition by id should succeed")
|
||||
.is_none());
|
||||
assert!(!repos
|
||||
.parquet_files()
|
||||
.exist(p1_n1.id)
|
||||
|
@ -4563,6 +4572,12 @@ pub(crate) mod test_helpers {
|
|||
.len(),
|
||||
3
|
||||
);
|
||||
assert!(repos
|
||||
.partitions()
|
||||
.get_by_id(partition_2.id)
|
||||
.await
|
||||
.expect("fetching partition by id should succeed")
|
||||
.is_some());
|
||||
assert!(repos
|
||||
.parquet_files()
|
||||
.exist(p1_n2.id)
|
||||
|
|
|
@ -361,6 +361,10 @@ impl NamespaceRepo for MemTxn {
|
|||
.iter()
|
||||
.filter_map(|table| (table.namespace_id == namespace_id).then_some(table.id))
|
||||
.collect();
|
||||
// delete partitions for those tables
|
||||
stage
|
||||
.partitions
|
||||
.retain(|p| !table_ids.iter().any(|id| *id == p.table_id));
|
||||
// delete tombstones for those tables
|
||||
stage
|
||||
.tombstones
|
||||
|
|
|
@ -680,8 +680,26 @@ WHERE name = $1;
|
|||
Ok(Some(namespace))
|
||||
}
|
||||
|
||||
async fn delete(&mut self, _name: &str) -> Result<()> {
|
||||
todo!()
|
||||
async fn delete(&mut self, name: &str) -> Result<()> {
|
||||
// note that there is a uniqueness constraint on the name column in the DB
|
||||
sqlx::query(
|
||||
r#"
|
||||
WITH namespace_id as (
|
||||
SELECT id
|
||||
FROM namespace
|
||||
WHERE name = $1
|
||||
LIMIT 1
|
||||
)
|
||||
DELETE FROM namespace
|
||||
WHERE id = (SELECT id FROM namespace_id)
|
||||
RETURNING id;
|
||||
"#,
|
||||
)
|
||||
.bind(name)
|
||||
.execute(&mut self.inner)
|
||||
.await
|
||||
.context(interface::CouldNotDeleteNamespaceSnafu)
|
||||
.map(|_| ())
|
||||
}
|
||||
|
||||
async fn update_table_limit(&mut self, name: &str, new_max: i32) -> Result<Namespace> {
|
||||
|
|
|
@ -65,6 +65,15 @@ impl proto::namespace_service_server::NamespaceService for NamespaceServiceImpl
|
|||
))
|
||||
}
|
||||
|
||||
async fn delete_namespace(
|
||||
&self,
|
||||
_request: tonic::Request<proto::DeleteNamespaceRequest>,
|
||||
) -> Result<tonic::Response<proto::DeleteNamespaceResponse>, tonic::Status> {
|
||||
Err(tonic::Status::unimplemented(
|
||||
"use router instances to manage namespaces",
|
||||
))
|
||||
}
|
||||
|
||||
async fn update_namespace_retention(
|
||||
&self,
|
||||
_request: tonic::Request<proto::UpdateNamespaceRetentionRequest>,
|
||||
|
|
Loading…
Reference in New Issue