Crate locksmith

Source
Expand description

§Locksmith

This crate provides the logic for detecting the impact of a given SQL statement on a Postgres database.

It is the brains behind locksmith-cli.

§Detecting the impact of a statement

use locksmith::QueryOracle;

async fn inspect_statement() {
    let mut oracle = QueryOracle::new("postgres://localhost:5432/mydb");
    let inspection = oracle.inspect_statement("alter table customers alter column id type bigint;").await.unwrap();
    println!("{:?}", inspection.locks);
}

Structs§

ColumnObject
A column in a given table, with a data type
ConnectionID
A Postgres connection ID. Connections IDs can be retrieved via the pg_backend_pid function.
IndexObject
An index on a table, identified by its name
InspectedStatement
InspectedStatement is a struct that contains the side effects of inspecting a SQL statement. It includes the objects that were added, removed, locked, and rewritten by the statement.
QueryOracle
TableLock
A lock on a specific table
TableObject
A table, identified by its name

Enums§

DBObject
A database object, which can be a table, column, or index
Lock
A lock