Skip to content

Commit 0b1c109

Browse files
committed
store: update namespace handling in table creation and index loading
1 parent 086104f commit 0b1c109

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

store/postgres/src/relational.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ impl Table {
16801680
pub fn new_like(&self, namespace: &Namespace, name: &SqlName) -> Arc<Table> {
16811681
let other = Table {
16821682
object: self.object.clone(),
1683-
nsp: self.nsp.clone(),
1683+
nsp: namespace.clone(),
16841684
name: name.clone(),
16851685
qualified_name: SqlName::qualified_name(namespace, name),
16861686
columns: self.columns.clone(),

store/postgres/src/relational/ddl.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -403,13 +403,7 @@ impl Table {
403403
if index_def.is_some() && ENV_VARS.postpone_attribute_index_creation {
404404
let arr = index_def
405405
.unwrap()
406-
.indexes_for_table(
407-
&catalog.site.namespace,
408-
&self.name.to_string(),
409-
&self,
410-
false,
411-
false,
412-
)
406+
.indexes_for_table(&self.nsp, &self.name.to_string(), &self, false, false)
413407
.map_err(|_| fmt::Error)?;
414408
for (_, sql) in arr {
415409
writeln!(out, "{};", sql).expect("properly formated index statements")

store/postgres/src/relational/index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl CreateIndex {
440440
}
441441
}
442442

443-
fn with_nsp(&self, nsp2: String) -> Result<Self, Error> {
443+
pub fn with_nsp(&self, nsp2: String) -> Result<Self, Error> {
444444
let s = self.clone();
445445
match s {
446446
CreateIndex::Unknown { defn: _ } => Err(anyhow!("Failed to parse the index")),

store/postgres/src/relational/prune.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{collections::HashMap, fmt::Write, sync::Arc, time::Instant};
1+
use std::{collections::HashMap, fmt::Write, sync::Arc};
22

33
use diesel::{
44
connection::SimpleConnection,
@@ -23,7 +23,10 @@ use crate::{
2323
vid_batcher::{VidBatcher, VidRange},
2424
};
2525

26-
use super::{Catalog, Layout, Namespace};
26+
use super::{
27+
index::{load_indexes_from_table, CreateIndex, IndexList},
28+
Catalog, Layout, Namespace,
29+
};
2730

2831
/// Utility to copy relevant data out of a source table and into a new
2932
/// destination table and replace the source table with the destination
@@ -59,7 +62,10 @@ impl TablePair {
5962
let mut list = IndexList {
6063
indexes: HashMap::new(),
6164
};
62-
let indexes = load_indexes_from_table(conn, &src, src_nsp.as_str())?;
65+
let indexes = load_indexes_from_table(conn, &src, src_nsp.as_str())?
66+
.into_iter()
67+
.map(|index| index.with_nsp(dst_nsp.to_string()))
68+
.collect::<Result<Vec<CreateIndex>, _>>()?;
6369
list.indexes.insert(src.name.to_string(), indexes);
6470

6571
// In case of pruning we don't do delayed creation of indexes,

0 commit comments

Comments
 (0)