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
ShowConfig
SHOW CONFIG [prefix]
SetSecret
SET SECRET key = value
DeleteSecret
DELETE SECRET key
ShowSecrets
SHOW SECRET[S] [prefix]
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.
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.
DropIamPolicy
DROP POLICY '<id>' — removes an IAM policy and its
attachments.
AttachPolicy
ATTACH POLICY '<id>' TO USER <name> /
ATTACH POLICY '<id>' TO GROUP <name>.
DetachPolicy
DETACH POLICY '<id>' FROM USER <name> /
DETACH POLICY '<id>' FROM GROUP <name>.
ShowPolicies
SHOW POLICIES [FOR USER <name> | FOR GROUP <name>].
Fields
filter: Option<PolicyPrincipalRef>ShowEffectivePermissions
SHOW EFFECTIVE PERMISSIONS FOR <name> [ON <kind>:<name>].
SimulatePolicy
SIMULATE <name> ACTION <verb> ON <kind>:<name>.
Implementations§
Source§impl QueryExpr
impl QueryExpr
Sourcepub fn table(name: &str) -> TableQueryBuilder
pub fn table(name: &str) -> TableQueryBuilder
Create a table query
Sourcepub fn graph() -> GraphQueryBuilder
pub fn graph() -> GraphQueryBuilder
Create a graph query
Sourcepub fn path(from: NodeSelector, to: NodeSelector) -> PathQueryBuilder
pub fn path(from: NodeSelector, to: NodeSelector) -> PathQueryBuilder
Create a path query
Trait Implementations§
Auto Trait Implementations§
impl Freeze for QueryExpr
impl RefUnwindSafe for QueryExpr
impl Send for QueryExpr
impl Sync for QueryExpr
impl Unpin for QueryExpr
impl UnsafeUnpin for QueryExpr
impl UnwindSafe for QueryExpr
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request