Skip to main content

Pragma

Enum Pragma 

Source
pub enum Pragma {
Show 74 variants ApplicationId(i32), AutoVacuum(AutoVacuum), CacheSize(i32), ForeignKeys(bool), JournalMode(JournalMode), WalAutocheckpoint(i32), Synchronous(Synchronous), TempStore(TempStore), LockingMode(LockingMode), SecureDelete(SecureDelete), UserVersion(i32), Encoding(Encoding), PageSize(i32), MmapSize(i64), RecursiveTriggers(bool), AnalysisLimit(i32), AutomaticIndex(bool), BusyTimeout(i32), CacheSpill(CacheSpill), CaseSensitiveLike(bool), CellSizeCheck(bool), CheckpointFullFsync(bool), CountChanges(bool), DataStoreDirectory(&'static str), DefaultCacheSize(i32), DeferForeignKeys(bool), EmptyResultCallbacks(bool), FullColumnNames(bool), FullFsync(bool), HardHeapLimit(i64), IgnoreCheckConstraints(bool), JournalSizeLimit(i64), LegacyAlterTable(bool), LegacyFileFormat, MaxPageCount(i32), QueryOnly(bool), ReadUncommitted(bool), ReverseUnorderedSelects(bool), SchemaVersion(i32), ShortColumnNames(bool), SoftHeapLimit(i64), TempStoreDirectory(&'static str), Threads(i32), TrustedSchema(bool), WritableSchema(WritableSchema), ParserTrace(bool), VdbeAddoptrace(bool), VdbeDebug(bool), VdbeListing(bool), VdbeTrace(bool), CollationList, CompileOptions, DatabaseList, FunctionList, TableList, TableXInfo(&'static str), ModuleList, DataVersion, FreelistCount, PageCount, PragmaList, Stats, IncrementalVacuum(Option<i32>), ShrinkMemory, WalCheckpoint(Option<WalCheckpointMode>), IntegrityCheck(Option<&'static str>), QuickCheck(Option<&'static str>), Optimize(Option<u32>), ForeignKeyCheck(Option<&'static str>), TableInfo(&'static str), IndexList(&'static str), IndexInfo(&'static str), IndexXInfo(&'static str), ForeignKeyList(&'static str),
}
Expand description

A SQLite PRAGMA statement.

Variants are grouped as settings, read-only queries, maintenance commands, and per-table queries. A setting variant renders an assignment (PRAGMA cache_size = -2000); to read a setting’s current value, use Pragma::query. Names passed to variants (tables, indexes, directories) are not quoted or escaped.

Variants§

§

ApplicationId(i32)

Sets the 32-bit signed big-endian application ID

SQLite Documentation

§Examples

let pragma = Pragma::ApplicationId(12345);
assert_eq!(pragma.to_sql().sql(), "PRAGMA application_id = 12345");
§

AutoVacuum(AutoVacuum)

Sets the auto-vacuum mode

SQLite Documentation

§Examples

let pragma = Pragma::AutoVacuum(AutoVacuum::Full);
assert_eq!(pragma.to_sql().sql(), "PRAGMA auto_vacuum = FULL");
§

CacheSize(i32)

Sets the suggested page cache size: pages if positive, KiB if negative

SQLite Documentation

§Examples

let pragma = Pragma::CacheSize(-2000);
assert_eq!(pragma.to_sql().sql(), "PRAGMA cache_size = -2000");
§

ForeignKeys(bool)

Turns foreign key enforcement on or off

SQLite Documentation

§Examples

let pragma = Pragma::ForeignKeys(true);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_keys = ON");

let pragma = Pragma::ForeignKeys(false);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_keys = OFF");
§

JournalMode(JournalMode)

Sets the journal mode for databases

SQLite Documentation

§Examples

let pragma = Pragma::JournalMode(JournalMode::Wal);
assert_eq!(pragma.to_sql().sql(), "PRAGMA journal_mode = WAL");
§

WalAutocheckpoint(i32)

Sets the WAL auto-checkpoint threshold (pages)

SQLite Documentation

§Examples

let pragma = Pragma::WalAutocheckpoint(1000);
assert_eq!(pragma.to_sql().sql(), "PRAGMA wal_autocheckpoint = 1000");
§

Synchronous(Synchronous)

Sets how often SQLite syncs writes to disk

SQLite Documentation

§Examples

let pragma = Pragma::Synchronous(Synchronous::Normal);
assert_eq!(pragma.to_sql().sql(), "PRAGMA synchronous = NORMAL");
§

TempStore(TempStore)

Sets the storage mode used by temporary tables and indices

SQLite Documentation

§Examples

let pragma = Pragma::TempStore(TempStore::Memory);
assert_eq!(pragma.to_sql().sql(), "PRAGMA temp_store = MEMORY");
§

LockingMode(LockingMode)

Sets the connection’s locking mode

SQLite Documentation

§Examples

let pragma = Pragma::LockingMode(LockingMode::Exclusive);
assert_eq!(pragma.to_sql().sql(), "PRAGMA locking_mode = EXCLUSIVE");
§

SecureDelete(SecureDelete)

Sets the secure-delete setting

SQLite Documentation

§Examples

let pragma = Pragma::SecureDelete(SecureDelete::Fast);
assert_eq!(pragma.to_sql().sql(), "PRAGMA secure_delete = FAST");
§

UserVersion(i32)

Sets the user-version integer

SQLite Documentation

§Examples

let pragma = Pragma::UserVersion(42);
assert_eq!(pragma.to_sql().sql(), "PRAGMA user_version = 42");
§

Encoding(Encoding)

Sets the text encoding used by the database

SQLite Documentation

§Examples

let pragma = Pragma::Encoding(Encoding::Utf8);
assert_eq!(pragma.to_sql().sql(), "PRAGMA encoding = UTF-8");
§

PageSize(i32)

Sets the database page size in bytes

SQLite Documentation

§Examples

let pragma = Pragma::PageSize(4096);
assert_eq!(pragma.to_sql().sql(), "PRAGMA page_size = 4096");
§

MmapSize(i64)

Sets the maximum memory map size

SQLite Documentation

§Examples

let pragma = Pragma::MmapSize(268435456);
assert_eq!(pragma.to_sql().sql(), "PRAGMA mmap_size = 268435456");
§

RecursiveTriggers(bool)

Enable or disable recursive trigger firing

SQLite Documentation

§Examples

let pragma = Pragma::RecursiveTriggers(true);
assert_eq!(pragma.to_sql().sql(), "PRAGMA recursive_triggers = ON");
§

AnalysisLimit(i32)

Sets the ANALYZE limit

SQLite Documentation

§

AutomaticIndex(bool)

Sets automatic indexing

SQLite Documentation

§

BusyTimeout(i32)

Sets the busy timeout (milliseconds)

SQLite Documentation

§

CacheSpill(CacheSpill)

Sets cache spill settings

SQLite Documentation

§

CaseSensitiveLike(bool)

Sets case_sensitive_like (deprecated)

SQLite Documentation

§

CellSizeCheck(bool)

Enable or disable cell size checking

SQLite Documentation

§

CheckpointFullFsync(bool)

Enable or disable checkpoint fullfsync

SQLite Documentation

§

CountChanges(bool)

Sets count_changes (deprecated)

SQLite Documentation

§

DataStoreDirectory(&'static str)

Sets data_store_directory (deprecated)

SQLite Documentation

§

DefaultCacheSize(i32)

Sets default_cache_size (deprecated)

SQLite Documentation

§

DeferForeignKeys(bool)

Sets defer_foreign_keys

SQLite Documentation

§

EmptyResultCallbacks(bool)

Sets empty_result_callbacks (deprecated)

SQLite Documentation

§

FullColumnNames(bool)

Sets full_column_names (deprecated)

SQLite Documentation

§

FullFsync(bool)

Sets fullfsync

SQLite Documentation

§

HardHeapLimit(i64)

Sets hard_heap_limit

SQLite Documentation

§

IgnoreCheckConstraints(bool)

Sets ignore_check_constraints

SQLite Documentation

§

JournalSizeLimit(i64)

Sets journal_size_limit

SQLite Documentation

§

LegacyAlterTable(bool)

Sets legacy_alter_table

SQLite Documentation

§

LegacyFileFormat

Query legacy_file_format (deprecated)

SQLite Documentation

§

MaxPageCount(i32)

Sets max_page_count

SQLite Documentation

§

QueryOnly(bool)

Sets query_only

SQLite Documentation

§

ReadUncommitted(bool)

Sets read_uncommitted

SQLite Documentation

§

ReverseUnorderedSelects(bool)

Sets reverse_unordered_selects

SQLite Documentation

§

SchemaVersion(i32)

Sets schema_version. Misuse can corrupt the database

SQLite Documentation

§

ShortColumnNames(bool)

Sets short_column_names (deprecated)

SQLite Documentation

§

SoftHeapLimit(i64)

Sets soft_heap_limit

SQLite Documentation

§

TempStoreDirectory(&'static str)

Sets temp_store_directory (deprecated)

SQLite Documentation

§

Threads(i32)

Sets threads

SQLite Documentation

§

TrustedSchema(bool)

Sets trusted_schema

SQLite Documentation

§

WritableSchema(WritableSchema)

Sets writable_schema. Misuse can corrupt the database

SQLite Documentation

§

ParserTrace(bool)

Sets parser_trace (requires SQLITE_DEBUG)

SQLite Documentation

§

VdbeAddoptrace(bool)

Sets vdbe_addoptrace (requires SQLITE_DEBUG)

SQLite Documentation

§

VdbeDebug(bool)

Sets vdbe_debug (requires SQLITE_DEBUG)

SQLite Documentation

§

VdbeListing(bool)

Sets vdbe_listing (requires SQLITE_DEBUG)

SQLite Documentation

§

VdbeTrace(bool)

Sets vdbe_trace (requires SQLITE_DEBUG)

SQLite Documentation

§

CollationList

Return a list of collating sequences

SQLite Documentation

§Examples

let pragma = Pragma::CollationList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA collation_list");
§

CompileOptions

Return compile-time options used when building SQLite

SQLite Documentation

§Examples

let pragma = Pragma::CompileOptions;
assert_eq!(pragma.to_sql().sql(), "PRAGMA compile_options");
§

DatabaseList

Return information about attached databases

SQLite Documentation

§Examples

let pragma = Pragma::DatabaseList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA database_list");
§

FunctionList

Return a list of SQL functions

SQLite Documentation

§Examples

let pragma = Pragma::FunctionList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA function_list");
§

TableList

Return information about tables and views in the schema

SQLite Documentation

§Examples

let pragma = Pragma::TableList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_list");
§

TableXInfo(&'static str)

Return extended table information including hidden columns

SQLite Documentation

§Examples

let pragma = Pragma::TableXInfo("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_xinfo(users)");
§

ModuleList

Return a list of available virtual table modules

SQLite Documentation

§Examples

let pragma = Pragma::ModuleList;
assert_eq!(pragma.to_sql().sql(), "PRAGMA module_list");
§

DataVersion

Return the data_version counter

SQLite Documentation

§

FreelistCount

Return the number of free pages in the database file

SQLite Documentation

§

PageCount

Return the page count for the database

SQLite Documentation

§

PragmaList

Return a list of available pragmas

SQLite Documentation

§

Stats

Return statistics (test-only)

SQLite Documentation

§

IncrementalVacuum(Option<i32>)

Perform incremental vacuuming

SQLite Documentation

§

ShrinkMemory

Release as much memory as possible

SQLite Documentation

§

WalCheckpoint(Option<WalCheckpointMode>)

Run a WAL checkpoint

SQLite Documentation

§

IntegrityCheck(Option<&'static str>)

Perform database integrity check

SQLite Documentation

§Examples

// Check entire database
let pragma = Pragma::IntegrityCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA integrity_check");

// Check specific table
let pragma = Pragma::IntegrityCheck(Some("users"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA integrity_check(users)");
§

QuickCheck(Option<&'static str>)

Perform faster database integrity check

SQLite Documentation

§Examples

let pragma = Pragma::QuickCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA quick_check");

let pragma = Pragma::QuickCheck(Some("users"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA quick_check(users)");
§

Optimize(Option<u32>)

Attempt to optimize the database

SQLite Documentation

§Examples

let pragma = Pragma::Optimize(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA optimize");

let pragma = Pragma::Optimize(Some(0x10002));
assert_eq!(pragma.to_sql().sql(), "PRAGMA optimize(65538)");
§

ForeignKeyCheck(Option<&'static str>)

Check foreign key constraints for a table

SQLite Documentation

§Examples

let pragma = Pragma::ForeignKeyCheck(None);
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_check");

let pragma = Pragma::ForeignKeyCheck(Some("orders"));
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_check(orders)");
§

TableInfo(&'static str)

Return information about table columns

SQLite Documentation

§Examples

let pragma = Pragma::TableInfo("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA table_info(users)");
§

IndexList(&'static str)

Return information about table indexes

SQLite Documentation

§Examples

let pragma = Pragma::IndexList("users");
assert_eq!(pragma.to_sql().sql(), "PRAGMA index_list(users)");
§

IndexInfo(&'static str)

Return information about index columns

SQLite Documentation

§Examples

let pragma = Pragma::IndexInfo("idx_users_email");
assert_eq!(pragma.to_sql().sql(), "PRAGMA index_info(idx_users_email)");
§

IndexXInfo(&'static str)

Return extended information about index columns

SQLite Documentation

§

ForeignKeyList(&'static str)

Return foreign key information for a table

SQLite Documentation

§Examples

let pragma = Pragma::ForeignKeyList("orders");
assert_eq!(pragma.to_sql().sql(), "PRAGMA foreign_key_list(orders)");

Implementations§

Source§

impl Pragma

Source

pub fn query(pragma_name: &str) -> SQL<'static, SQLiteValue<'static>>

Builds PRAGMA name, which reads the pragma’s current value.

pragma_name is written into the SQL as given; only pass trusted names.

§Examples
assert_eq!(Pragma::query("journal_mode").sql(), "PRAGMA journal_mode");
Source

pub const fn foreign_keys(enabled: bool) -> Self

Source

pub const fn journal_mode(mode: JournalMode) -> Self

Source

pub const fn wal_autocheckpoint(pages: i32) -> Self

Source

pub const fn table_info(table: &'static str) -> Self

Source

pub const fn index_list(table: &'static str) -> Self

Source

pub const fn foreign_key_list(table: &'static str) -> Self

Source

pub const fn integrity_check(table: Option<&'static str>) -> Self

Source

pub const fn foreign_key_check(table: Option<&'static str>) -> Self

Source

pub const fn table_xinfo(table: &'static str) -> Self

Source

pub const fn encoding(encoding: Encoding) -> Self

Trait Implementations§

Source§

impl Clone for Pragma

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 Pragma

Source§

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

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

impl Eq for Pragma

Source§

impl PartialEq for Pragma

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 Pragma

Source§

impl<'a> ToSQL<'a, SQLiteValue<'a>> for Pragma

Source§

fn to_sql(&self) -> SQL<'a, SQLiteValue<'a>>

Renders self as a SQL fragment.
Source§

fn into_sql(self) -> SQL<'a, V>
where Self: Sized,

Renders self as a SQL fragment, consuming it. Read more

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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<Joined, From> JoinKey<From, JoinReverse> for Joined
where From: Joinable<Joined> + ?Sized,

Source§

fn pairs() -> &'static [(&'static str, &'static str)]

(joined_column, from_column) pairs the ON condition matches, in key order, read through Self::pair.
Source§

fn pair(pair: &(&'static str, &'static str)) -> (&'static str, &'static str)

The (joined_column, from_column) names of pair.
Source§

impl<List> ListIncludes<Nil, ()> for List

Source§

impl<Mk> MarkerAggValidFor<()> for Mk

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.
Source§

impl<T> TypeEq<T> for T