2019-08-11 16:55:18 +02:00
|
|
|
package mysql
|
|
|
|
|
|
2026-05-14 16:26:47 +00:00
|
|
|
import "source.gleipnir.technology/Gleipnir/jet/internal/jet"
|
2019-08-11 16:55:18 +02:00
|
|
|
|
2019-08-17 10:43:16 +02:00
|
|
|
// LockStatement is interface for MySQL LOCK tables
|
2019-08-11 16:55:18 +02:00
|
|
|
type LockStatement interface {
|
|
|
|
|
Statement
|
|
|
|
|
READ() Statement
|
|
|
|
|
WRITE() Statement
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-17 10:43:16 +02:00
|
|
|
// LOCK creates LockStatement from list of tables
|
2019-08-11 16:55:18 +02:00
|
|
|
func LOCK(tables ...jet.SerializerTable) LockStatement {
|
|
|
|
|
newLock := &lockStatementImpl{
|
|
|
|
|
Lock: jet.ClauseStatementBegin{Name: "LOCK TABLES", Tables: tables},
|
|
|
|
|
Read: jet.ClauseOptional{Name: "READ"},
|
|
|
|
|
Write: jet.ClauseOptional{Name: "WRITE"},
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-17 18:32:01 +02:00
|
|
|
newLock.SerializerStatement = jet.NewStatementImpl(Dialect, jet.LockStatementType, newLock, &newLock.Lock, &newLock.Read, &newLock.Write)
|
2019-08-11 16:55:18 +02:00
|
|
|
|
|
|
|
|
return newLock
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type lockStatementImpl struct {
|
2019-08-17 18:32:01 +02:00
|
|
|
jet.SerializerStatement
|
2019-08-11 16:55:18 +02:00
|
|
|
|
|
|
|
|
Lock jet.ClauseStatementBegin
|
|
|
|
|
Read jet.ClauseOptional
|
|
|
|
|
Write jet.ClauseOptional
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *lockStatementImpl) READ() Statement {
|
|
|
|
|
l.Read.Show = true
|
|
|
|
|
return l
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (l *lockStatementImpl) WRITE() Statement {
|
|
|
|
|
l.Write.Show = true
|
|
|
|
|
return l
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-17 10:43:16 +02:00
|
|
|
// UNLOCK_TABLES explicitly releases any table locks held by the current session
|
2019-08-11 16:55:18 +02:00
|
|
|
func UNLOCK_TABLES() Statement {
|
|
|
|
|
newUnlock := &unlockStatementImpl{
|
|
|
|
|
Unlock: jet.ClauseStatementBegin{Name: "UNLOCK TABLES"},
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-17 18:32:01 +02:00
|
|
|
newUnlock.SerializerStatement = jet.NewStatementImpl(Dialect, jet.UnLockStatementType, newUnlock, &newUnlock.Unlock)
|
2019-08-11 16:55:18 +02:00
|
|
|
|
|
|
|
|
return newUnlock
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type unlockStatementImpl struct {
|
2019-08-17 18:32:01 +02:00
|
|
|
jet.SerializerStatement
|
2019-08-11 16:55:18 +02:00
|
|
|
Unlock jet.ClauseStatementBegin
|
|
|
|
|
}
|