pgrx::spi

Trait Query

Source
pub trait Query<'conn>: Sized {
    type Arguments;

    // Required methods
    fn execute(
        self,
        client: &SpiClient<'conn>,
        limit: Option<c_long>,
        args: Self::Arguments,
    ) -> SpiResult<SpiTupleTable<'conn>>;
    fn try_open_cursor(
        self,
        client: &SpiClient<'conn>,
        args: Self::Arguments,
    ) -> SpiResult<SpiCursor<'conn>>;

    // Provided method
    fn open_cursor(
        self,
        client: &SpiClient<'conn>,
        args: Self::Arguments,
    ) -> SpiCursor<'conn> { ... }
}
Expand description

A generalized interface to what constitutes a query

Its primary purpose is to abstract away differences between one-off statements and prepared statements, but it can potentially be implemented for other types, provided they can be converted into a query.

Required Associated Types§

Required Methods§

Source

fn execute( self, client: &SpiClient<'conn>, limit: Option<c_long>, args: Self::Arguments, ) -> SpiResult<SpiTupleTable<'conn>>

Execute a query given a client and other arguments.

Source

fn try_open_cursor( self, client: &SpiClient<'conn>, args: Self::Arguments, ) -> SpiResult<SpiCursor<'conn>>

Tries to open cursor for the query.

Provided Methods§

Source

fn open_cursor( self, client: &SpiClient<'conn>, args: Self::Arguments, ) -> SpiCursor<'conn>

Open a cursor for the query.

§Panics

Panics if a cursor wasn’t opened.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'conn> Query<'conn> for &str

Source§

type Arguments = Option<Vec<(PgOid, Option<Datum>)>>

Source§

fn execute( self, _client: &SpiClient<'conn>, limit: Option<c_long>, args: Self::Arguments, ) -> SpiResult<SpiTupleTable<'conn>>

Source§

fn try_open_cursor( self, _client: &SpiClient<'conn>, args: Self::Arguments, ) -> SpiResult<SpiCursor<'conn>>

Source§

impl<'conn> Query<'conn> for &String

Source§

type Arguments = Option<Vec<(PgOid, Option<Datum>)>>

Source§

fn execute( self, _client: &SpiClient<'conn>, limit: Option<c_long>, args: Self::Arguments, ) -> SpiResult<SpiTupleTable<'conn>>

Source§

fn try_open_cursor( self, _client: &SpiClient<'conn>, args: Self::Arguments, ) -> SpiResult<SpiCursor<'conn>>

Source§

impl<'conn> Query<'conn> for &CStr

Source§

type Arguments = Option<Vec<(PgOid, Option<Datum>)>>

Source§

fn execute( self, _client: &SpiClient<'conn>, limit: Option<c_long>, args: Self::Arguments, ) -> SpiResult<SpiTupleTable<'conn>>

Source§

fn try_open_cursor( self, _client: &SpiClient<'conn>, args: Self::Arguments, ) -> SpiResult<SpiCursor<'conn>>

Implementors§

Source§

impl<'conn> Query<'conn> for &CString

Source§

impl<'conn> Query<'conn> for &OwnedPreparedStatement

Source§

impl<'conn> Query<'conn> for OwnedPreparedStatement

Source§

impl<'conn> Query<'conn> for PreparedStatement<'conn>

Source§

impl<'conn: 'stmt, 'stmt> Query<'conn> for &'stmt PreparedStatement<'conn>