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:
Peter Štibraný
2025-07-03 10:38:12 +02:00
committed by GitHub
co-authored by Mustafa Sencer Özcan
parent a68f8107df
commit e076c74869
7 changed files with 69 additions and 127 deletions
@@ -2,28 +2,29 @@ package sqltemplate
import (
"errors"
"fmt"
"strings"
)
// PostgreSQL is an implementation of Dialect for the PostgreSQL DMBS.
var PostgreSQL = postgresql{
rowLockingClauseMap: rowLockingClauseAll,
argPlaceholderFunc: argFmtPositional,
name: "postgres",
}
var PostgreSQL = postgresql{}
var _ Dialect = PostgreSQL
// PostgreSQL-specific errors.
var (
ErrPostgreSQLUnsupportedIdent = errors.New("identifiers in PostgreSQL cannot contain the character with code zero")
)
type postgresql struct {
standardIdent
rowLockingClauseMap
argPlaceholderFunc
name
type postgresql struct{}
func (p postgresql) DialectName() string {
return "postgres"
}
func (p postgresql) ArgPlaceholder(argNum int) string {
return fmt.Sprintf("$%d", argNum)
}
func (p postgresql) SelectFor(s ...string) (string, error) {
return rowLockingClauseAll.SelectFor(s...)
}
func (p postgresql) Ident(s string) (string, error) {
@@ -33,7 +34,7 @@ func (p postgresql) Ident(s string) (string, error) {
return "", ErrPostgreSQLUnsupportedIdent
}
return p.standardIdent.Ident(s)
return standardIdent(s)
}
func (postgresql) CurrentEpoch() string {