Skip to main content

Literal

Enum Literal 

Source
pub enum Literal {
Show 14 variants Integer(i64), Float(f64), Numeric { unscaled: i128, scale: u16, }, NumericBig(String), String(String), Timestamp { micros: i64, text: String, }, Date { days: i32, text: String, }, Bool(bool), Null, Vector(Vec<f32>), TextArray(Vec<Option<String>>), IntArray(Vec<Option<i32>>), BigIntArray(Vec<Option<i64>>), Interval { months: i32, days: i32, micros: i64, text: String, },
}

Variants§

§

Integer(i64)

§

Float(f64)

§

Numeric

Exact decimal literal — a bare 12.34-style token, kept as unscaled / 10^scale so no precision or trailing-zero scale is lost before it becomes a Value::Numeric. PG parses such literals as numeric, not double precision. (Scientific/huge literals stay Float.)

Fields

§unscaled: i128
§scale: u16

v7.39 (round 271) — widened to u16. At u8 a literal with more than 255 decimal places could not be represented, and the conversion’s .expect("lexer-validated decimal") aborted the query with an internal error on SQL PG accepts.

§

NumericBig(String)

v7.38 (read01, T3.C3) — an exact decimal literal whose mantissa overflows i128 (kept as its source digit string, [-]digits[.digits]). Becomes a Value::NumericBig at eval; previously such literals fell back to double.

§

String(String)

§

Timestamp

v7.38.8 — a temporal constant that has already been decoded.

Without these the only way to carry one through the AST was as text, and a predicate comparing a timestamp column against a literal then coerced that text back into a timestamp ONCE PER ROW — 32 ns of the 52 a comparison cost, measured on a customer profile. constfold produced text for the same reason: its exit had nothing else to hand back.

text keeps the spelling so Display round-trips byte for byte, the way Interval already does and for the same reason: this node is printed in EXPLAIN, in dumps and in error messages, and none of those should change because the value stopped being carried as a string. The enum already holds a String and an i128, so neither variant widens it.

Fields

§micros: i64
§text: String
§

Date

Days since the epoch Value::Date counts from. See Literal::Timestamp.

Fields

§days: i32
§text: String
§

Bool(bool)

§

Null

§

Vector(Vec<f32>)

pgvector-style array literal, e.g. [1, 2.5, -3].

§

TextArray(Vec<Option<String>>)

TEXT[] value carried through the prepared-bind path (= ANY($1) has no column context to re-parse a {a,b} text form, so the array rides the AST natively).

§

IntArray(Vec<Option<i32>>)

INT[] value carried through the prepared-bind path.

§

BigIntArray(Vec<Option<i64>>)

BIGINT[] value carried through the prepared-bind path.

§

Interval

INTERVAL '<n> <unit> [<n> <unit> ...]' — calendar-aware span. Three independent dimensions: months (variable-length; year/month), days (fixed 86400 seconds at non-DST, but preserved as its own dimension so '1 day''24 hours' stays distinguishable), and micros (sub-day; can carry). text keeps the original spelling so Display round-trips byte-for-byte. v7.37.5 β added the days field for PG parity.

Fields

§months: i32
§days: i32
§micros: i64
§text: String

Trait Implementations§

Source§

impl Clone for Literal

Source§

fn clone(&self) -> Literal

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 Literal

Source§

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

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

impl Display for Literal

Source§

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

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

impl PartialEq for Literal

Source§

fn eq(&self, other: &Literal) -> 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 Literal

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.