Files
grafana/pkg/services/store/entity/sqlstash/sqltemplate/dialect_postgresql.go
T
Diego Augusto Molina acf17c7fb1 Unified Storage: Add SQL template package (#87524)
* added sqltemplate package

* addded example

* fix linting issues

* improve code readability

* fix documentation
2024-05-08 17:58:18 -03:00

35 lines
741 B
Go

package sqltemplate
import (
"errors"
"strings"
)
// PostgreSQL is an implementation of Dialect for the PostgreSQL DMBS.
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
}
func (p postgresql) Ident(s string) (string, error) {
// See:
// https://www.postgresql.org/docs/current/sql-syntax-lexical.html
if strings.IndexByte(s, 0) != -1 {
return "", ErrPostgreSQLUnsupportedIdent
}
return p.standardIdent.Ident(s)
}
func (postgresql) SelectFor(s ...string) (string, error) {
return rowLockingClauseAll(true).SelectFor(s...)
}