Skip to main content

IndexInfoConstraint

Struct IndexInfoConstraint 

Source
pub struct IndexInfoConstraint<'a> { /* private fields */ }

Implementations§

Source§

impl IndexInfoConstraint<'_>

Source

pub fn column(&self) -> i32

Return the column being constrained. The value is a 0-based index of columns as declared by connect / create. The rowid column is index -1.

Source

pub fn op(&self) -> ConstraintOp

Return the type of constraint.

Source

pub fn usable(&self) -> bool

IndexInfo::constraints contains information about all constraints that apply to the virtual table, but some of the constraints might not be usable because of the way tables are ordered in a join. The best_index method must therefore only consider constraints that for which this method returns true.

Source

pub fn rhs(&self) -> Result<&ValueRef>

Returns the right-hand side of the constraint.

This routine attempts to retrieve the value of the right-hand operand of the constraint if that operand is known. If the operand is not known, then Err(SQLITE_NOTFOUND) is returned. This method can return another error type if something goes wrong.

This method is usually only successful if the right-hand operand of a constraint is a literal value in the original SQL statement. If the right-hand operand is an expression or a reference to some other column or a host parameter, then this method will probably return Err(SQLITE_NOTFOUND).

Some constraints, such as ConstraintOp::IsNull, have no right-hand operand. For such constraints, this method always returns Err(SQLITE_NOTFOUND).

Requires SQLite 3.38.0. On earlier versions of SQLite, Err(SQLITE_NOTFOUND) is always returned.

Source

pub fn collation(&self) -> Result<&str>

Return the collation to use for text comparisons on this column.

See the SQLite documentation for more details.

Source

pub fn argv_index(&self) -> Option<u32>

Retrieve the value previously set using set_argv_index.

Source

pub fn set_argv_index(&mut self, idx: Option<u32>)

Set the desired index for filter’s argv.

Exactly one entry in the IndexInfo should be set to 0, another to 1, another to 2, and so forth up to as many or as few as the best_index method wants. The EXPR of the corresponding constraints will then be passed in as the argv[] parameters to filter.

Source

pub fn omit(&self) -> bool

Retrieve the value previously set by set_omit.

Source

pub fn set_omit(&mut self, val: bool)

Advise SQLite that this constraint is validated by the virtual table implementation. SQLite may skip performing its own check in some cases. It is generally a hint and not a requirement, but a notable exception is for ConstraintOp::Offset, which is always honored. See the SQLite documentation for more details.

Source

pub fn value_list_available(&self) -> bool

Check if all values in this IN constraint are able to be processed simultaneously. If this method returns true, then a call to set_value_list_wanted would also return true.

Requires SQLite 3.38.0. On earlier versions, this function will always return false.

Source

pub fn set_value_list_wanted(&mut self, val: bool) -> bool

Instruct SQLite to return all values in an IN constraint simultaneously.

A constraint on a virtual table in the form of “column IN (…)” is communicated to VTab::best_index as a ConstraintOp::Eq constraint. If the virtual table wants to use this constraint, it must use set_argv_index to assign the constraint to an argument. Then, SQLite will invoke VTabCursor::filter once for each value on the right-hand side of the IN operator. Thus, the virtual table only sees a single value from the right-hand side of the IN operator at a time.

In some cases, however, it would be advantageous for the virtual table to see all values on the right-hand of the IN operator all at once. This method enables this feature.

Calling this method with true will request ValueList processing. In order for ValueList processing to work:

  1. this constraint must be assigned an argv index using set_argv_index;
  2. this method is called with true; and
  3. SQLite is able to provide all values simultaneously.

If all of these criteria are met, then the corresponding argument passed to VTabCursor::filter will appear to be SQL NULL, but accessible using ValueList. If this facility is requested but this method returns false, then VTabCursor::filter will be invoked multiple times with each different value of the constraint, as normal.

This method always returns the same value that value_list_available would. Calling this method with false cancels a previous request for a ValueList.

See the SQLite documentation for more details.

Requires SQLite 3.38.0. On earlier versions, this function will always return false.

Trait Implementations§

Source§

impl<'a> Clone for IndexInfoConstraint<'a>

Source§

fn clone(&self) -> IndexInfoConstraint<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IndexInfoConstraint<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a> Copy for IndexInfoConstraint<'a>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.