sqltemplate, dbimpl: Remove single-method function types (#107525)
* Remove dbProviderFunc function. This removes one extra indirection that made the code bit more difficult to navigate. * Remove indirection function types implementing single-method interfaces. This streamlines the code and makes it bit easier to navigate. * Update pkg/storage/unified/sql/sqltemplate/dialect_mysql.go Co-authored-by: Mustafa Sencer Özcan <32759850+mustafasencer@users.noreply.github.com> --------- Co-authored-by: Mustafa Sencer Özcan <32759850+mustafasencer@users.noreply.github.com>
This commit is contained in:
co-authored by
Mustafa Sencer Özcan
parent
a68f8107df
commit
e076c74869
@@ -6,26 +6,17 @@ import (
|
||||
|
||||
// MySQL is the default implementation of Dialect for the MySQL DMBS,
|
||||
// currently supporting MySQL-8.x.
|
||||
var MySQL = mysql{
|
||||
rowLockingClauseMap: rowLockingClauseAll,
|
||||
argPlaceholderFunc: argFmtSQL92,
|
||||
name: "mysql",
|
||||
var MySQL = mysql{}
|
||||
|
||||
type mysql struct{}
|
||||
|
||||
func (m mysql) DialectName() string {
|
||||
return "mysql"
|
||||
}
|
||||
|
||||
var _ Dialect = MySQL
|
||||
|
||||
type mysql struct {
|
||||
backtickIdent
|
||||
rowLockingClauseMap
|
||||
argPlaceholderFunc
|
||||
name
|
||||
}
|
||||
|
||||
// MySQL always supports backticks for identifiers
|
||||
// https://dev.mysql.com/doc/refman/8.4/en/identifiers.html
|
||||
type backtickIdent struct{}
|
||||
|
||||
func (backtickIdent) Ident(s string) (string, error) {
|
||||
func (m mysql) Ident(s string) (string, error) {
|
||||
// MySQL always supports backticks for identifiers
|
||||
// https://dev.mysql.com/doc/refman/8.4/en/identifiers.html
|
||||
if strings.ContainsRune(s, '`') {
|
||||
return "", ErrInvalidIdentInput
|
||||
}
|
||||
@@ -34,6 +25,14 @@ func (backtickIdent) Ident(s string) (string, error) {
|
||||
})
|
||||
}
|
||||
|
||||
func (m mysql) ArgPlaceholder(argNum int) string {
|
||||
return "?"
|
||||
}
|
||||
|
||||
func (m mysql) SelectFor(s ...string) (string, error) {
|
||||
return rowLockingClauseAll.SelectFor(s...)
|
||||
}
|
||||
|
||||
func (mysql) CurrentEpoch() string {
|
||||
return "CAST(FLOOR(UNIX_TIMESTAMP(NOW(6)) * 1000000) AS SIGNED)"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user