mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 01:00:33 +08:00

* Use epoch with microsecond resolution as RV * fix backend tests * Add solution for when the clock goes back * Add solution for when the clock goes back * generate mocks * go lint * remove comment * Use Greatest instead of max in msyql and postgres * update tests * Update pkg/storage/unified/sql/sqltemplate/dialect_sqlite.go Co-authored-by: Diego Augusto Molina <diegoaugustomolina@gmail.com> * cast to bigint * add additional round trip * increment the RV using 2 sql round trips instead of 3 * cleanup comments * cast unix timestamp to integer * fix postgres query * remove old increment test data * remove greatest * cast unix_timestamp to signed * Use statement_timestamp instead of clock_timestamp --------- Co-authored-by: Diego Augusto Molina <diegoaugustomolina@gmail.com>
40 lines
833 B
Go
40 lines
833 B
Go
package sqltemplate
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// 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 _ 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) {
|
|
if strings.ContainsRune(s, '`') {
|
|
return "", ErrInvalidIdentInput
|
|
}
|
|
return escapeIdentity(s, '`', func(s string) string {
|
|
return s
|
|
})
|
|
}
|
|
|
|
func (mysql) CurrentEpoch() string {
|
|
return "CAST(FLOOR(UNIX_TIMESTAMP(NOW(6)) * 1000000) AS SIGNED)"
|
|
}
|