Chore: Make cgo optional (for sqlite) (#108756)

* make cgo optional for sqlite

* update go.mod; check error code differently

* reduce api surface even more

* move test errors into sqlite package

* add a comment
This commit is contained in:
Serge Zaitsev
2025-07-31 09:25:19 +00:00
committed by GitHub
parent f39b878b0a
commit 6b1143565a
15 changed files with 160 additions and 41 deletions
+3 -4
View File
@@ -10,9 +10,9 @@ import (
"time"
"github.com/go-sql-driver/mysql"
"github.com/grafana/grafana/pkg/util/sqlite"
"github.com/jackc/pgx/v5/pgconn"
"github.com/lib/pq"
"github.com/mattn/go-sqlite3"
"github.com/prometheus/client_golang/prometheus"
"go.opentelemetry.io/otel/trace"
"go.opentelemetry.io/otel/trace/noop"
@@ -389,9 +389,8 @@ func (b *backend) create(ctx context.Context, event resource.WriteEvent) (int64,
// IsRowAlreadyExistsError checks if the error is the result of the row inserted already existing.
func IsRowAlreadyExistsError(err error) bool {
var sqlite sqlite3.Error
if errors.As(err, &sqlite) {
return sqlite.ExtendedCode == sqlite3.ErrConstraintUnique
if sqlite.IsUniqueConstraintViolation(err) {
return true
}
var pg *pgconn.PgError