arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Sql.Groups

Description

Internal to the arbiter packages. Not covered by the PVP.

Groups SQL templates.

Synopsis

Documentation

groupsWindowSQL :: SchemaName -> TableName -> Int -> Maybe Text -> Query TextSource #

At most limit group keys past cursor, in the database's key order, unlocked. Its last key is the caller's resume cursor.

emptiedWindowSQL :: SchemaName -> TableName -> Int -> Maybe Text -> Query TextSource #

At most limit keys past cursor the maintenance triggers emptied in place, in the database's key order. Its last key is the caller's resume cursor.

lockGroupsSQL :: SchemaName -> TableName -> Maybe Text -> Maybe Text -> [Text] -> Query TextSource #

FOR UPDATE SKIP LOCKED over the window groupsWindowSQL returned plus the keys emptiedWindowSQL returned, one ascending pass in the key order the maintenance triggers use. Returns the keys this transaction holds.

refreshGroupsSQL :: SchemaName -> TableName -> [Text] -> Query Int64Source #

Recompute the groups table, scoped to the locked keys from lockGroupsSQL. Deletes the summary of a key with no jobs left. Returns the count of rows updated or deleted. A separate statement whose snapshot post-dates the lock.

insertMissingGroupsSQL :: SchemaName -> TableName -> Int -> Maybe Text -> Maybe Text -> Query (Text, Bool)Source #

Insert summary rows for grouped jobs that have none, at most limit keys past lower up to upper, in key order. Returns each key and whether its insert landed.

settleGroupLocksCte :: SchemaName -> TableName -> Text -> [Text] -> TextSource #

A group_locks CTE over the group rows of the deleted and updated CTEs, in key order, taken only when an updated CTE changed a row. The DELETE trigger and the UPDATE trigger each lock in key order, but the DELETE trigger runs first.

lockGroupKeysSQL :: SchemaName -> TableName -> [Text] -> Query ()Source #

Create the missing group summaries among keys and lock them all, in key order.