pub struct IndexInfo { /* private fields */ }
Expand description
Wraps the raw sqlite3_index_info C struct, which represents the possible constraints and outputs the xBestIndex method should use and return. https://www.sqlite.org/c3ref/index_info.html
Implementations§
Source§impl IndexInfo
impl IndexInfo
Sourcepub fn constraints(&self) -> Vec<Constraint>
pub fn constraints(&self) -> Vec<Constraint>
Examples found in repository?
examples/characters.rs (line 51)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 57)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
pub fn order_bys(&self) -> Vec<OrderBy>
Sourcepub fn set_idxnum(&mut self, value: i32)
pub fn set_idxnum(&mut self, value: i32)
Examples found in repository?
examples/characters.rs (line 70)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 85)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
pub fn set_idxstr(&mut self, value: &str) -> Result<()>
Sourcepub fn set_estimated_rows(&mut self, value: i64)
pub fn set_estimated_rows(&mut self, value: i64)
Examples found in repository?
examples/characters.rs (line 69)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 84)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
Sourcepub fn set_estimated_cost(&mut self, value: f64)
pub fn set_estimated_cost(&mut self, value: f64)
“The estimatedCost field should be set to the estimated number of disk access operations required to execute this query against the virtual table.” https://www.sqlite.org/vtab.html#outputs
Examples found in repository?
examples/characters.rs (line 68)
49 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
50 let mut has_input = false;
51 for mut constraint in info.constraints() {
52 match column(constraint.column_idx()) {
53 Some(Columns::Input) => {
54 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
55 constraint.set_omit(true);
56 constraint.set_argv_index(1);
57 has_input = true;
58 } else {
59 return Err(BestIndexError::Constraint);
60 }
61 }
62 _ => todo!(),
63 }
64 }
65 if !has_input {
66 return Err(BestIndexError::Error);
67 }
68 info.set_estimated_cost(100000.0);
69 info.set_estimated_rows(100000);
70 info.set_idxnum(1);
71
72 Ok(())
73 }
More examples
examples/series.rs (line 83)
54 fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
55 let mut has_start = false;
56 let mut has_stop = false;
57 for mut constraint in info.constraints() {
58 match column(constraint.column_idx()) {
59 Some(Columns::Start) => {
60 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
61 constraint.set_omit(true);
62 constraint.set_argv_index(1);
63 has_start = true;
64 } else {
65 return Err(BestIndexError::Constraint);
66 }
67 }
68 Some(Columns::Stop) => {
69 if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
70 constraint.set_omit(true);
71 constraint.set_argv_index(2);
72 has_stop = true;
73 } else {
74 return Err(BestIndexError::Constraint);
75 }
76 }
77 _ => todo!(),
78 }
79 }
80 if !has_start || !has_stop {
81 return Err(BestIndexError::Error);
82 }
83 info.set_estimated_cost(100000.0);
84 info.set_estimated_rows(100000);
85 info.set_idxnum(1);
86
87 Ok(())
88 }
pub fn columns_used(&self) -> u64
pub fn distinct(&self) -> i32
Trait Implementations§
Auto Trait Implementations§
impl Freeze for IndexInfo
impl RefUnwindSafe for IndexInfo
impl !Send for IndexInfo
impl !Sync for IndexInfo
impl Unpin for IndexInfo
impl UnwindSafe for IndexInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more