MCPcopy Index your code
hub / github.com/simstudioai/sim / acquireRowOrderLock

Function acquireRowOrderLock

apps/sim/lib/table/rows/ordering.ts:52–56  ·  view source on GitHub ↗
(trx: DbTransaction, tableId: string)

Source from the content-addressed store, hash-verified

50 * restores per-table serialization. Released at COMMIT/ROLLBACK.
51 */
52export async function acquireRowOrderLock(trx: DbTransaction, tableId: string) {
53 await trx.execute(
54 sql`SELECT pg_advisory_xact_lock(hashtextextended(${`user_table_rows_pos:${tableId}`}, 0))`
55 )
56}
57
58/** Next append position for a table (max(position) + 1, or 0 if empty). */
59export async function nextRowPosition(trx: DbTransaction, tableId: string): Promise<number> {

Callers 8

importAppendRowsFunction · 0.90
importReplaceRowsFunction · 0.90
batchInsertRowsWithTxFunction · 0.90
replaceTableRowsWithTxFunction · 0.90
upsertRowFunction · 0.90
reserveInsertPositionFunction · 0.85
reserveBatchPositionsFunction · 0.85
insertOrderedRowFunction · 0.85

Calls 1

executeMethod · 0.65

Tested by

no test coverage detected