Skip to main content

ColumnInfo

Struct ColumnInfo 

Source
pub struct ColumnInfo {
Show 14 fields pub name: Vec<u8>, pub folded: Vec<u8>, pub declared_type: Vec<u8>, pub affinity: Affinity, pub collation: Vec<u8>, pub not_null: bool, pub not_null_conflict: Option<ConflictAction>, pub primary_key_conflict: Option<ConflictAction>, pub default_sql: Option<Vec<u8>>, pub primary_key_position: Option<u16>, pub hidden: bool, pub generated: bool, pub stored: bool, pub generated_sql: Option<Vec<u8>>,
}
Expand description

One column of a table or view.

Fields§

§name: Vec<u8>

The name as declared.

§folded: Vec<u8>

The ASCII-folded lookup key.

§declared_type: Vec<u8>

The declared type, exactly as written, empty when none was given.

§affinity: Affinity

The affinity derived from the declared type.

§collation: Vec<u8>

The folded name of the column’s declared collation.

§not_null: bool

Whether the column is NOT NULL.

§not_null_conflict: Option<ConflictAction>

The ON CONFLICT clause written on the NOT NULL, when there was one.

A constraint carries its own algorithm and the statement may override it: INSERT OR IGNORE beats NOT NULL ON CONFLICT ABORT. Recording it per constraint rather than per table is what makes that override a choice between two known values instead of a guess.

§primary_key_conflict: Option<ConflictAction>

The ON CONFLICT clause written on the column’s PRIMARY KEY.

A different constraint from the NOT NULL, and a different clause. For a rowid alias this is the only place a rowid collision’s algorithm is written down - SQLite records id INTEGER PRIMARY KEY ON CONFLICT REPLACE against the column, because the alias is the column and there is no index to hang it on. Every other primary key gets an IndexInfo and carries it there.

Reading not_null_conflict for it, which is what the write path used to do, answers a question about a constraint the table may not even declare.

§default_sql: Option<Vec<u8>>

The DEFAULT expression, as written.

§primary_key_position: Option<u16>

The one-based position in the primary key, when it is in one.

§hidden: bool

Whether the column is hidden from SELECT *.

§generated: bool

Whether the column is generated.

§stored: bool

Whether a generated column’s value is stored in the record.

A VIRTUAL column occupies no slot and is computed on every read; a STORED one occupies a slot like any other column. The distinction is not cosmetic: it changes which record position every column after it lives at, so a reader that ignored it would read the wrong column.

§generated_sql: Option<Vec<u8>>

The generating expression, as the source text it was written as.

Implementations§

Source§

impl ColumnInfo

Source

pub fn is_vector(&self) -> bool

Reports whether the column was declared a vector at all.

VECTOR(768) and a bare VECTOR both answer true, where ColumnInfo::vector_dimensions answers a width only for the first. The difference matters to the operators: a bare VECTOR cannot be indexed, but adding two of them is just as meaningless.

Source

pub fn vector_dimensions(&self) -> Option<usize>

Returns how many dimensions a VECTOR(N) column declares.

Read out of the declared type rather than stored beside it, because every path that builds a ColumnInfo - the catalog loader, a module’s declaration, the binder’s synthetic ones - would otherwise have to know about vectors, and a column’s declared type is the one place SQLite itself keeps what a column was called.

VECTOR(768) and vector( 768 ) both answer 768. A bare VECTOR answers None, which means “a vector of whatever arrives” and is what a table holding two models’ embeddings needs; anything that is not a vector answers None too, and its caller then checks nothing.

The affinity is deliberately left alone. SQLite gives VECTOR(768) NUMERIC affinity, and NUMERIC leaves a blob exactly as it arrived - so the bytes round-trip without this engine having to disagree with the reference about what an affinity is. What the declaration buys is the width check on write, and a column an index can be built over.

Trait Implementations§

Source§

impl Clone for ColumnInfo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ColumnInfo

Source§

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

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

impl Eq for ColumnInfo

Source§

impl PartialEq for ColumnInfo

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ColumnInfo

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.