Struct sqlite_loadable::table::Constraint
source · pub struct Constraint {
pub constraint: sqlite3_index_info_sqlite3_index_constraint,
pub usage: *mut sqlite3_index_info_sqlite3_index_constraint_usage,
}Expand description
Wraps the raw sqlite3_index_constraint and sqlite3_index_constraint_usage C structs for ergonomic use in Rust.
Fields§
§constraint: sqlite3_index_info_sqlite3_index_constraint§usage: *mut sqlite3_index_info_sqlite3_index_constraint_usageImplementations§
source§impl Constraint
impl Constraint
sourcepub fn column_idx(&self) -> i32
pub fn column_idx(&self) -> i32
Examples found in repository?
examples/characters.rs (line 52)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_input = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Input) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_input = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_input {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}More examples
examples/series.rs (line 58)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_start = false;
let mut has_stop = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Start) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_start = true;
} else {
return Err(BestIndexError::Constraint);
}
}
Some(Columns::Stop) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(2);
has_stop = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_start || !has_stop {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}sourcepub fn usable(&self) -> bool
pub fn usable(&self) -> bool
Examples found in repository?
examples/characters.rs (line 54)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_input = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Input) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_input = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_input {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}More examples
examples/series.rs (line 60)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_start = false;
let mut has_stop = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Start) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_start = true;
} else {
return Err(BestIndexError::Constraint);
}
}
Some(Columns::Stop) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(2);
has_stop = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_start || !has_stop {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}sourcepub fn op(&self) -> Option<ConstraintOperator>
pub fn op(&self) -> Option<ConstraintOperator>
Examples found in repository?
examples/characters.rs (line 54)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_input = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Input) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_input = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_input {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}More examples
examples/series.rs (line 60)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_start = false;
let mut has_stop = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Start) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_start = true;
} else {
return Err(BestIndexError::Constraint);
}
}
Some(Columns::Stop) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(2);
has_stop = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_start || !has_stop {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}sourcepub fn set_argv_index(&mut self, i: i32)
pub fn set_argv_index(&mut self, i: i32)
Examples found in repository?
examples/characters.rs (line 56)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_input = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Input) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_input = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_input {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}More examples
examples/series.rs (line 62)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_start = false;
let mut has_stop = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Start) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_start = true;
} else {
return Err(BestIndexError::Constraint);
}
}
Some(Columns::Stop) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(2);
has_stop = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_start || !has_stop {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}sourcepub fn set_omit(&mut self, value: bool)
pub fn set_omit(&mut self, value: bool)
Examples found in repository?
examples/characters.rs (line 55)
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_input = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Input) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_input = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_input {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}More examples
examples/series.rs (line 61)
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
fn best_index(&self, mut info: IndexInfo) -> core::result::Result<(), BestIndexError> {
let mut has_start = false;
let mut has_stop = false;
for mut constraint in info.constraints() {
match column(constraint.column_idx()) {
Some(Columns::Start) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(1);
has_start = true;
} else {
return Err(BestIndexError::Constraint);
}
}
Some(Columns::Stop) => {
if constraint.usable() && constraint.op() == Some(ConstraintOperator::EQ) {
constraint.set_omit(true);
constraint.set_argv_index(2);
has_stop = true;
} else {
return Err(BestIndexError::Constraint);
}
}
_ => todo!(),
}
}
if !has_start || !has_stop {
return Err(BestIndexError::Error);
}
info.set_estimated_cost(100000.0);
info.set_estimated_rows(100000);
info.set_idxnum(1);
Ok(())
}