Skip to main content

QueryExpr

Enum QueryExpr 

Source
pub enum QueryExpr {
Show 78 variants Table(TableQuery), Graph(GraphQuery), Join(JoinQuery), Path(PathQuery), Vector(VectorQuery), Hybrid(HybridQuery), Insert(InsertQuery), Update(UpdateQuery), Delete(DeleteQuery), CreateTable(CreateTableQuery), CreateCollection(CreateCollectionQuery), CreateVector(CreateVectorQuery), DropTable(DropTableQuery), DropGraph(DropGraphQuery), DropVector(DropVectorQuery), DropDocument(DropDocumentQuery), DropKv(DropKvQuery), DropCollection(DropCollectionQuery), Truncate(TruncateQuery), AlterTable(AlterTableQuery), GraphCommand(GraphCommand), SearchCommand(SearchCommand), Ask(AskQuery), CreateIndex(CreateIndexQuery), DropIndex(DropIndexQuery), ProbabilisticCommand(ProbabilisticCommand), CreateTimeSeries(CreateTimeSeriesQuery), DropTimeSeries(DropTimeSeriesQuery), CreateQueue(CreateQueueQuery), AlterQueue(AlterQueueQuery), DropQueue(DropQueueQuery), QueueSelect(QueueSelectQuery), QueueCommand(QueueCommand), KvCommand(KvCommand), ConfigCommand(ConfigCommand), CreateTree(CreateTreeQuery), DropTree(DropTreeQuery), TreeCommand(TreeCommand), SetConfig { key: String, value: Value, }, ShowConfig { prefix: Option<String>, }, SetSecret { key: String, value: Value, }, DeleteSecret { key: String, }, ShowSecrets { prefix: Option<String>, }, SetTenant(Option<String>), ShowTenant, ExplainAlter(ExplainAlterQuery), CreateMigration(CreateMigrationQuery), ApplyMigration(ApplyMigrationQuery), RollbackMigration(RollbackMigrationQuery), ExplainMigration(ExplainMigrationQuery), EventsBackfill(EventsBackfillQuery), EventsBackfillStatus { collection: String, }, TransactionControl(TxnControl), MaintenanceCommand(MaintenanceCommand), CreateSchema(CreateSchemaQuery), DropSchema(DropSchemaQuery), CreateSequence(CreateSequenceQuery), DropSequence(DropSequenceQuery), CopyFrom(CopyFromQuery), CreateView(CreateViewQuery), DropView(DropViewQuery), RefreshMaterializedView(RefreshMaterializedViewQuery), CreatePolicy(CreatePolicyQuery), DropPolicy(DropPolicyQuery), CreateServer(CreateServerQuery), DropServer(DropServerQuery), CreateForeignTable(CreateForeignTableQuery), DropForeignTable(DropForeignTableQuery), Grant(GrantStmt), Revoke(RevokeStmt), AlterUser(AlterUserStmt), CreateIamPolicy { id: String, json: String, }, DropIamPolicy { id: String, }, AttachPolicy { policy_id: String, principal: PolicyPrincipalRef, }, DetachPolicy { policy_id: String, principal: PolicyPrincipalRef, }, ShowPolicies { filter: Option<PolicyPrincipalRef>, }, ShowEffectivePermissions { user: PolicyUserRef, resource: Option<PolicyResourceRef>, }, SimulatePolicy { user: PolicyUserRef, action: String, resource: PolicyResourceRef, },
}
Expand description

Root query expression

Variants§

§

Table(TableQuery)

Pure table query: SELECT … FROM …

§

Graph(GraphQuery)

Pure graph query: MATCH … RETURN …

§

Join(JoinQuery)

Join between table and graph

§

Path(PathQuery)

Path query: PATH FROM … TO …

§

Vector(VectorQuery)

Vector similarity search

§

Hybrid(HybridQuery)

Hybrid query combining structured and vector search

§

Insert(InsertQuery)

INSERT INTO table (cols) VALUES (vals)

§

Update(UpdateQuery)

UPDATE table SET col=val WHERE filter

§

Delete(DeleteQuery)

DELETE FROM table WHERE filter

§

CreateTable(CreateTableQuery)

CREATE TABLE name (columns)

§

CreateCollection(CreateCollectionQuery)

CREATE COLLECTION name KIND kind

§

CreateVector(CreateVectorQuery)

CREATE VECTOR name DIM n [METRIC metric]

§

DropTable(DropTableQuery)

DROP TABLE name

§

DropGraph(DropGraphQuery)

DROP GRAPH name

§

DropVector(DropVectorQuery)

DROP VECTOR name

§

DropDocument(DropDocumentQuery)

DROP DOCUMENT name

§

DropKv(DropKvQuery)

DROP KV name

§

DropCollection(DropCollectionQuery)

DROP COLLECTION name

§

Truncate(TruncateQuery)

TRUNCATE [model] name

§

AlterTable(AlterTableQuery)

ALTER TABLE name ADD/DROP/RENAME COLUMN

§

GraphCommand(GraphCommand)

GRAPH subcommand (NEIGHBORHOOD, SHORTEST_PATH, etc.)

§

SearchCommand(SearchCommand)

SEARCH subcommand (SIMILAR, TEXT, HYBRID)

§

Ask(AskQuery)

ASK ‘question’ — RAG query with LLM synthesis

§

CreateIndex(CreateIndexQuery)

CREATE INDEX name ON table (columns) USING type

§

DropIndex(DropIndexQuery)

DROP INDEX name ON table

§

ProbabilisticCommand(ProbabilisticCommand)

Probabilistic data structure commands (HLL, SKETCH, FILTER)

§

CreateTimeSeries(CreateTimeSeriesQuery)

CREATE TIMESERIES name [RETENTION duration] [CHUNK_SIZE n]

§

DropTimeSeries(DropTimeSeriesQuery)

DROP TIMESERIES name

§

CreateQueue(CreateQueueQuery)

CREATE QUEUE name [MAX_SIZE n] [PRIORITY] [WITH TTL duration]

§

AlterQueue(AlterQueueQuery)

ALTER QUEUE name SET MODE [FANOUT|WORK]

§

DropQueue(DropQueueQuery)

DROP QUEUE name

§

QueueSelect(QueueSelectQuery)

Read-only queue projection: SELECT … FROM QUEUE name

§

QueueCommand(QueueCommand)

QUEUE subcommand (PUSH, POP, PEEK, LEN, PURGE, GROUP, READ, ACK, NACK)

§

KvCommand(KvCommand)

KV subcommand (PUT, GET, DELETE)

§

ConfigCommand(ConfigCommand)

CONFIG keyed command (PUT, GET, ROTATE, DELETE, HISTORY)

§

CreateTree(CreateTreeQuery)

CREATE TREE name IN collection ROOT … MAX_CHILDREN n

§

DropTree(DropTreeQuery)

DROP TREE name IN collection

§

TreeCommand(TreeCommand)

TREE subcommand (INSERT, MOVE, DELETE, VALIDATE, REBALANCE)

§

SetConfig

SET CONFIG key = value

Fields

§value: Value
§

ShowConfig

SHOW CONFIG [prefix]

Fields

§prefix: Option<String>
§

SetSecret

SET SECRET key = value

Fields

§value: Value
§

DeleteSecret

DELETE SECRET key

Fields

§

ShowSecrets

SHOW SECRET[S] [prefix]

Fields

§prefix: Option<String>
§

SetTenant(Option<String>)

SET TENANT 'id' / SET TENANT = 'id' / RESET TENANT

Session-scoped multi-tenancy handle. Populates a per-connection thread-local that CURRENT_TENANT() reads and that RLS policies combine with via USING (tenant_id = CURRENT_TENANT()). None clears the current tenant (RESET TENANT or SET TENANT NULL). Unlike SetConfig this is not persisted to red_config — it lives for the connection’s lifetime only.

§

ShowTenant

SHOW TENANT — returns the thread-local tenant id (or NULL).

§

ExplainAlter(ExplainAlterQuery)

EXPLAIN ALTER FOR CREATE TABLE name (…) [FORMAT JSON]

Pure read command that diffs the embedded CREATE TABLE statement against the live CollectionContract of the table with the same name and returns the ALTER TABLE operations that would close the gap. Never executes anything — output is text (default) or JSON depending on the optional FORMAT JSON suffix. Powers the Purple framework’s migration generator and any other client that wants reddb to own the schema-diff rules.

§

CreateMigration(CreateMigrationQuery)

CREATE MIGRATION name [DEPENDS ON dep1, dep2] [BATCH n ROWS] [NO ROLLBACK] body

§

ApplyMigration(ApplyMigrationQuery)

APPLY MIGRATION name | APPLY MIGRATION * [FOR TENANT id]

§

RollbackMigration(RollbackMigrationQuery)

ROLLBACK MIGRATION name

§

ExplainMigration(ExplainMigrationQuery)

EXPLAIN MIGRATION name

§

EventsBackfill(EventsBackfillQuery)

EVENTS BACKFILL collection [WHERE pred] TO queue [LIMIT n].

§

EventsBackfillStatus

EVENTS BACKFILL STATUS collection placeholder for the status slice.

Fields

§collection: String
§

TransactionControl(TxnControl)

Transaction control: BEGIN, COMMIT, ROLLBACK, SAVEPOINT, RELEASE, ROLLBACK TO.

Phase 1.1 (PG parity): parser + dispatch are wired so clients (psql, JDBC, etc.) can issue these statements without errors. Real isolation/atomicity semantics arrive with Phase 2.3 MVCC. Until then statements behave as autocommit (each DML is its own transaction); BEGIN/COMMIT/ROLLBACK return success but do NOT provide rollback-on-failure guarantees across multiple statements.

§

MaintenanceCommand(MaintenanceCommand)

Maintenance commands: VACUUM [FULL] [table], ANALYZE [table].

Phase 1.2 (PG parity): VACUUM triggers segment/page flush + planner stats refresh. ANALYZE refreshes planner statistics (histograms, null counts, distinct estimates). Both accept an optional table target; omitting the target iterates every collection.

§

CreateSchema(CreateSchemaQuery)

CREATE SCHEMA [IF NOT EXISTS] name

Phase 1.3 (PG parity): schemas are logical namespaces stored in red_config under the key schema.{name}. Tables created inside a schema use schema.table qualified names (collection name = “schema.table”).

§

DropSchema(DropSchemaQuery)

DROP SCHEMA [IF EXISTS] name [CASCADE]

§

CreateSequence(CreateSequenceQuery)

CREATE SEQUENCE [IF NOT EXISTS] name [START [WITH] n] [INCREMENT [BY] n]

Phase 1.3 (PG parity): sequences are 64-bit monotonic counters persisted in red_config under the key sequence.{name}. Values are produced by the scalar functions nextval('name') and currval('name').

§

DropSequence(DropSequenceQuery)

DROP SEQUENCE [IF EXISTS] name

§

CopyFrom(CopyFromQuery)

COPY table FROM 'path' [WITH ...] — CSV import (Phase 1.5 PG parity).

Supported options: DELIMITER c, HEADER [true|false]. Rows stream into the named collection via the CsvImporter.

§

CreateView(CreateViewQuery)

CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS] name AS SELECT ...

Phase 2.1 (PG parity): views are stored as view.{name} entries in red_config. Materialized views additionally allocate a slot in the shared MaterializedViewCache; REFRESH MATERIALIZED VIEW re-runs the underlying query and repopulates the cache.

§

DropView(DropViewQuery)

DROP [MATERIALIZED] VIEW [IF EXISTS] name

§

RefreshMaterializedView(RefreshMaterializedViewQuery)

REFRESH MATERIALIZED VIEW name

Re-executes the view’s query and writes the result into the cache.

§

CreatePolicy(CreatePolicyQuery)

CREATE POLICY name ON table [FOR action] [TO role] USING (filter)

Phase 2.5 (PG parity): row-level security policy definition. Evaluated at read time — when the table has RLS enabled, all matching policies for the current role are combined with OR and AND-ed into the query’s WHERE clause.

§

DropPolicy(DropPolicyQuery)

DROP POLICY [IF EXISTS] name ON table

§

CreateServer(CreateServerQuery)

CREATE SERVER name FOREIGN DATA WRAPPER kind OPTIONS (...) (Phase 3.2 PG parity). Registers a named foreign-data-wrapper instance in the runtime’s ForeignTableRegistry.

§

DropServer(DropServerQuery)

DROP SERVER [IF EXISTS] name [CASCADE]

§

CreateForeignTable(CreateForeignTableQuery)

CREATE FOREIGN TABLE name (cols) SERVER srv OPTIONS (...) (Phase 3.2 PG parity). Makes name resolvable as a foreign table via the parent server’s ForeignDataWrapper.

§

DropForeignTable(DropForeignTableQuery)

DROP FOREIGN TABLE [IF EXISTS] name

§

Grant(GrantStmt)

GRANT { actions | ALL [PRIVILEGES] } ON { TABLE | SCHEMA | DATABASE | FUNCTION } object_list TO grant_principal_list [WITH GRANT OPTION]

Granular RBAC primitive layered on top of the legacy 3-role model. See crate::auth::privileges for the resolution algorithm.

§

Revoke(RevokeStmt)

REVOKE [GRANT OPTION FOR] { actions | ALL } ON … FROM …

§

AlterUser(AlterUserStmt)

ALTER USER name [VALID UNTIL 'ts'] [CONNECTION LIMIT n] [ENABLE | DISABLE] [SET search_path = ...]

§

CreateIamPolicy

CREATE POLICY '<id>' AS '<json>' — installs an IAM policy document in the AuthStore. Distinct from the RLS-flavoured CreatePolicy(CreatePolicyQuery) above (which uses CREATE POLICY name ON table ...); the parser disambiguates at parse time by inspecting the token after the policy name.

Fields

§json: String
§

DropIamPolicy

DROP POLICY '<id>' — removes an IAM policy and its attachments.

Fields

§

AttachPolicy

ATTACH POLICY '<id>' TO USER <name> / ATTACH POLICY '<id>' TO GROUP <name>.

Fields

§policy_id: String
§

DetachPolicy

DETACH POLICY '<id>' FROM USER <name> / DETACH POLICY '<id>' FROM GROUP <name>.

Fields

§policy_id: String
§

ShowPolicies

SHOW POLICIES [FOR USER <name> | FOR GROUP <name>].

§

ShowEffectivePermissions

SHOW EFFECTIVE PERMISSIONS FOR <name> [ON <kind>:<name>].

§

SimulatePolicy

SIMULATE <name> ACTION <verb> ON <kind>:<name>.

Fields

§action: String

Implementations§

Source§

impl QueryExpr

Source

pub fn table(name: &str) -> TableQueryBuilder

Create a table query

Source

pub fn graph() -> GraphQueryBuilder

Create a graph query

Source

pub fn path(from: NodeSelector, to: NodeSelector) -> PathQueryBuilder

Create a path query

Trait Implementations§

Source§

impl Clone for QueryExpr

Source§

fn clone(&self) -> QueryExpr

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 QueryExpr

Source§

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

Formats the value using the given formatter. 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more