mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-09 10:14:21 +01:00
schema: add Index::has_rowid
This commit is contained in:
@@ -810,6 +810,12 @@ pub struct Index {
|
||||
pub columns: Vec<IndexColumn>,
|
||||
pub unique: bool,
|
||||
pub ephemeral: bool,
|
||||
/// Does the index have a rowid as the last column?
|
||||
/// This is the case for btree indexes (persistent or ephemeral) that
|
||||
/// have been created based on a table with a rowid.
|
||||
/// For example, WITHOUT ROWID tables (not supported in Limbo yet),
|
||||
/// and SELECT DISTINCT ephemeral indexes will not have a rowid.
|
||||
pub has_rowid: bool,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -863,6 +869,7 @@ impl Index {
|
||||
columns: index_columns,
|
||||
unique,
|
||||
ephemeral: false,
|
||||
has_rowid: table.has_rowid,
|
||||
})
|
||||
}
|
||||
_ => todo!("Expected create index statement"),
|
||||
@@ -925,6 +932,7 @@ impl Index {
|
||||
columns: primary_keys,
|
||||
unique: true,
|
||||
ephemeral: false,
|
||||
has_rowid: table.has_rowid,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -956,6 +964,7 @@ impl Index {
|
||||
}],
|
||||
unique: true,
|
||||
ephemeral: false,
|
||||
has_rowid: table.has_rowid,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
@@ -1027,6 +1036,7 @@ impl Index {
|
||||
columns: index_cols.collect(),
|
||||
unique: true,
|
||||
ephemeral: false,
|
||||
has_rowid: table.has_rowid,
|
||||
}
|
||||
});
|
||||
indices.extend(unique_set_indices);
|
||||
|
||||
@@ -63,6 +63,7 @@ pub fn translate_create_index(
|
||||
.collect(),
|
||||
unique: unique_if_not_exists.0,
|
||||
ephemeral: false,
|
||||
has_rowid: tbl.has_rowid,
|
||||
});
|
||||
|
||||
// Allocate the necessary cursors:
|
||||
|
||||
@@ -101,6 +101,7 @@ pub fn init_loop(
|
||||
pos_in_table: 0,
|
||||
collation: None, // FIXME: this should be inferred from the expression
|
||||
}],
|
||||
has_rowid: false,
|
||||
unique: false,
|
||||
});
|
||||
let cursor_id = program.alloc_cursor_id(
|
||||
|
||||
@@ -633,6 +633,7 @@ mod tests {
|
||||
unique: true,
|
||||
ephemeral: false,
|
||||
root_page: 1,
|
||||
has_rowid: true,
|
||||
});
|
||||
available_indexes.insert("test_table".to_string(), vec![index]);
|
||||
|
||||
@@ -697,6 +698,7 @@ mod tests {
|
||||
unique: true,
|
||||
ephemeral: false,
|
||||
root_page: 1,
|
||||
has_rowid: true,
|
||||
});
|
||||
available_indexes.insert("table1".to_string(), vec![index1]);
|
||||
|
||||
@@ -807,6 +809,7 @@ mod tests {
|
||||
unique: true,
|
||||
ephemeral: false,
|
||||
root_page: 1,
|
||||
has_rowid: true,
|
||||
});
|
||||
available_indexes.insert(table_name.to_string(), vec![index]);
|
||||
});
|
||||
@@ -822,6 +825,7 @@ mod tests {
|
||||
unique: false,
|
||||
ephemeral: false,
|
||||
root_page: 1,
|
||||
has_rowid: true,
|
||||
});
|
||||
let order_id_idx = Arc::new(Index {
|
||||
name: "order_items_order_id_idx".to_string(),
|
||||
@@ -835,6 +839,7 @@ mod tests {
|
||||
unique: false,
|
||||
ephemeral: false,
|
||||
root_page: 1,
|
||||
has_rowid: true,
|
||||
});
|
||||
|
||||
available_indexes
|
||||
|
||||
@@ -786,6 +786,10 @@ fn ephemeral_index_build(
|
||||
ephemeral: true,
|
||||
table_name: table_reference.table.get_name().to_string(),
|
||||
root_page: 0,
|
||||
has_rowid: table_reference
|
||||
.table
|
||||
.btree()
|
||||
.map_or(false, |btree| btree.has_rowid),
|
||||
};
|
||||
|
||||
ephemeral_index
|
||||
|
||||
Reference in New Issue
Block a user