Skip to content

Commit 522d7f7

Browse files
author
Zoran Cvetkov
committed
rename helper function and make it complete
1 parent 6a28007 commit 522d7f7

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

graph/src/schema/entity_type.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,12 @@ impl EntityType {
151151
self.schema.is_object_type(self.atom)
152152
}
153153

154-
pub fn new_vid_form(&self) -> bool {
155-
self.schema.new_vid_form()
154+
// Changes the way the VID field is generated. It used to be autoincrement. Now its
155+
// based on block number and the order of the entities in a block. The latter
156+
// represents the write order across all entity types in the subgraph.
157+
pub fn strict_vid_order(&self) -> bool {
158+
// Currently the agregations entities don't have VIDs in insertion order
159+
self.schema.strict_vid_order() && self.is_object_type()
156160
}
157161
}
158162

graph/src/schema/input/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ impl InputSchema {
15891589
Some(EntityType::new(self.cheap_clone(), obj_type.name))
15901590
}
15911591

1592-
pub fn new_vid_form(&self) -> bool {
1592+
pub fn strict_vid_order(&self) -> bool {
15931593
self.inner.spec_version >= SPEC_VERSION_1_3_0
15941594
}
15951595
}

store/postgres/src/relational/ddl.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ impl Table {
116116
Ok(cols)
117117
}
118118

119-
// Currently the agregations entities don't have VIDs in insertion order
120-
let new_vid_form = self.object.new_vid_form() && self.object.is_object_type();
121-
let vid_type = if new_vid_form { "bigint" } else { "bigserial" };
119+
let vid_type = if self.object.strict_vid_order() {
120+
"bigint"
121+
} else {
122+
"bigserial"
123+
};
122124

123125
if self.immutable {
124126
writeln!(

store/postgres/src/relational/prune.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,6 @@ impl TablePair {
243243

244244
let vid_seq = format!("{}_{VID_COLUMN}_seq", self.src.name);
245245

246-
let old_vid_form = !(self.src.object.new_vid_form() && self.src.object.is_object_type());
247-
248246
let mut query = String::new();
249247

250248
// What we are about to do would get blocked by autovacuum on our
@@ -254,9 +252,9 @@ impl TablePair {
254252
"src" => src_nsp.as_str(), "error" => e.to_string());
255253
}
256254

257-
// Make sure the vid sequence
258-
// continues from where it was
259-
if old_vid_form {
255+
// Make sure the vid sequence continues from where it was in case
256+
// that we use autoincrementing order of the DB
257+
if !self.src.object.strict_vid_order() {
260258
writeln!(
261259
query,
262260
"select setval('{dst_nsp}.{vid_seq}', nextval('{src_nsp}.{vid_seq}'));"

store/postgres/src/relational_queries.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,7 +2548,7 @@ impl<'a> QueryFragment<Pg> for InsertQuery<'a> {
25482548
let out = &mut out;
25492549
out.unsafe_to_cache_prepared();
25502550

2551-
let new_vid_form = self.table.object.new_vid_form() && self.table.object.is_object_type();
2551+
let strict_vid_order = self.table.object.strict_vid_order();
25522552

25532553
// Construct a query
25542554
// insert into schema.table(column, ...)
@@ -2575,7 +2575,7 @@ impl<'a> QueryFragment<Pg> for InsertQuery<'a> {
25752575
out.push_sql(CAUSALITY_REGION_COLUMN);
25762576
};
25772577

2578-
if new_vid_form {
2578+
if strict_vid_order {
25792579
out.push_sql(", vid");
25802580
}
25812581
out.push_sql(") values\n");
@@ -2595,7 +2595,7 @@ impl<'a> QueryFragment<Pg> for InsertQuery<'a> {
25952595
out.push_sql(", ");
25962596
out.push_bind_param::<Integer, _>(&row.causality_region)?;
25972597
};
2598-
if new_vid_form {
2598+
if strict_vid_order {
25992599
out.push_sql(", ");
26002600
out.push_bind_param::<BigInt, _>(&row.vid)?;
26012601
}
@@ -5096,7 +5096,7 @@ impl<'a> QueryFragment<Pg> for CopyEntityBatchQuery<'a> {
50965096
fn walk_ast<'b>(&'b self, mut out: AstPass<'_, 'b, Pg>) -> QueryResult<()> {
50975097
out.unsafe_to_cache_prepared();
50985098

5099-
let new_vid_form = self.src.object.new_vid_form() && self.src.object.is_object_type();
5099+
let strict_vid_order = self.src.object.strict_vid_order();
51005100

51015101
// Construct a query
51025102
// insert into {dst}({columns})
@@ -5118,7 +5118,7 @@ impl<'a> QueryFragment<Pg> for CopyEntityBatchQuery<'a> {
51185118
out.push_sql(", ");
51195119
out.push_sql(CAUSALITY_REGION_COLUMN);
51205120
};
5121-
if new_vid_form {
5121+
if strict_vid_order {
51225122
out.push_sql(", vid");
51235123
}
51245124

@@ -5186,7 +5186,7 @@ impl<'a> QueryFragment<Pg> for CopyEntityBatchQuery<'a> {
51865186
));
51875187
}
51885188
}
5189-
if new_vid_form {
5189+
if strict_vid_order {
51905190
out.push_sql(", vid");
51915191
}
51925192

0 commit comments

Comments
 (0)