-
Notifications
You must be signed in to change notification settings - Fork 125
LOCK
go-jet edited this page Aug 19, 2019
·
3 revisions
LOCK statement obtains a table-level lock, waiting if necessary for any conflicting locks to be released.
More about LOCK statement can be found:
PostgreSQL - https://www.postgresql.org/docs/11/sql-lock.html
MySQL - https://dev.mysql.com/doc/refman/8.0/en/lock-tables.html
MariaDB - https://mariadb.com/kb/en/library/lock-tables/
Following clauses are supported:
-
IN(mode)
- mode specifies which locks this lock conflicts with.- For PostgreSQL mode can be:
LOCK_ACCESS_SHARE
LOCK_ROW_SHARE
LOCK_ROW_EXCLUSIVE
LOCK_SHARE_UPDATE_EXCLUSIVE
LOCK_SHARE
LOCK_SHARE_ROW_EXCLUSIVE
LOCK_EXCLUSIVE
LOCK_ACCESS_EXCLUSIVE
- For MySQL and MariaDB mode can be:
READ
WRITE
- For PostgreSQL mode can be:
-
NOWAIT()
- locked table should not wait for any conflicting locks to be released. If the specified lock(s) cannot be acquired immediately without waiting, the transaction is aborted.
lockStmt := Address.
LOCK().
IN(LOCK_ACCESS_SHARE).
NOWAIT()
Debug SQL of above statement:
LOCK TABLE dvds.address IN ACCESS SHARE MODE NOWAIT;
To execute update statement and get sql.Result:
res, err := lockStmt.Exec(db)
Use ExecContext
to provide context object to execution.
- Home
- Generator
- Model
- SQL Builder
- Query Result Mapping (QRM)
-
FAQ
- How to execute jet statement in SQL transaction?
- How to construct dynamic projection list?
- How to construct dynamic condition?
- How to use jet in multi-tenant environment?
- How to change model field type?
- How to use custom(or currently unsupported) functions and operators?
- How to use IN/NOT_IN with dynamic list of values?
- Scan stopped working after naming a destination type