pub fn drift(
client: &mut Client,
sql: &str,
allow: &[String],
grantees: &Grantees,
) -> Result<Drift, Error>Expand description
Compares the live database with sql, the spec’s whole SQL, in both directions.
Policies are compared by command, roles, permissive, USING and WITH CHECK, and functions and triggers by their whole definition. A function is also changed when PUBLIC may execute it live and the SQL revokes that, or may not and the SQL grants it. Where the SQL revokes a function from PUBLIC, each other role but its owner that may execute it live is reported as granted, unless the function is grantable and the role is one of grantees, and so is each default privilege that grants new functions in a definer schema, or in every schema, to a role other than the one whose functions it covers. Orphans are the policies on a governed table, and the functions in a definer schema or triggers calling them, that the SQL does not create.
Each generated object is created as a temporary copy and read back, so both sides are compared as Postgres deparses them. Nothing outside the session’s temporary schema is created, and the transaction is rolled back. An allow entry is an orphan’s object text, such as function auth.f(text), to leave unreported; an entry that matches no orphan is reported as stale.
§Errors
The SQL creates an object the manifest does not record, or a catalog query fails.