mirror of
https://github.com/grafana/grafana.git
synced 2025-12-23 21:34:21 +08:00
Compare commits
4 Commits
provisioni
...
remove-mys
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae0cf22b46 | ||
|
|
3b6b828cd9 | ||
|
|
1ac1ebd057 | ||
|
|
ffd34a8bb6 |
@@ -71,10 +71,6 @@ export interface FeatureToggles {
|
|||||||
*/
|
*/
|
||||||
showDashboardValidationWarnings?: boolean;
|
showDashboardValidationWarnings?: boolean;
|
||||||
/**
|
/**
|
||||||
* Use double quotes to escape keyword in a MySQL query
|
|
||||||
*/
|
|
||||||
mysqlAnsiQuotes?: boolean;
|
|
||||||
/**
|
|
||||||
* Rule backtesting API for alerting
|
* Rule backtesting API for alerting
|
||||||
*/
|
*/
|
||||||
alertingBacktesting?: boolean;
|
alertingBacktesting?: boolean;
|
||||||
|
|||||||
@@ -96,12 +96,6 @@ var (
|
|||||||
Stage: FeatureStageExperimental,
|
Stage: FeatureStageExperimental,
|
||||||
Owner: grafanaDashboardsSquad,
|
Owner: grafanaDashboardsSquad,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "mysqlAnsiQuotes",
|
|
||||||
Description: "Use double quotes to escape keyword in a MySQL query",
|
|
||||||
Stage: FeatureStageExperimental,
|
|
||||||
Owner: grafanaSearchAndStorageSquad,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Name: "alertingBacktesting",
|
Name: "alertingBacktesting",
|
||||||
Description: "Rule backtesting API for alerting",
|
Description: "Rule backtesting API for alerting",
|
||||||
|
|||||||
1
pkg/services/featuremgmt/toggles_gen.csv
generated
1
pkg/services/featuremgmt/toggles_gen.csv
generated
@@ -11,7 +11,6 @@ logRequestsInstrumentedAsUnknown,experimental,@grafana/grafana-backend-group,fal
|
|||||||
grpcServer,preview,@grafana/search-and-storage,false,false,false
|
grpcServer,preview,@grafana/search-and-storage,false,false,false
|
||||||
cloudWatchCrossAccountQuerying,GA,@grafana/aws-datasources,false,false,false
|
cloudWatchCrossAccountQuerying,GA,@grafana/aws-datasources,false,false,false
|
||||||
showDashboardValidationWarnings,experimental,@grafana/dashboards-squad,false,false,false
|
showDashboardValidationWarnings,experimental,@grafana/dashboards-squad,false,false,false
|
||||||
mysqlAnsiQuotes,experimental,@grafana/search-and-storage,false,false,false
|
|
||||||
alertingBacktesting,experimental,@grafana/alerting-squad,false,false,false
|
alertingBacktesting,experimental,@grafana/alerting-squad,false,false,false
|
||||||
logsContextDatasourceUi,GA,@grafana/observability-logs,false,false,true
|
logsContextDatasourceUi,GA,@grafana/observability-logs,false,false,true
|
||||||
lokiShardSplitting,experimental,@grafana/observability-logs,false,false,true
|
lokiShardSplitting,experimental,@grafana/observability-logs,false,false,true
|
||||||
|
|||||||
|
4
pkg/services/featuremgmt/toggles_gen.go
generated
4
pkg/services/featuremgmt/toggles_gen.go
generated
@@ -47,10 +47,6 @@ const (
|
|||||||
// Show warnings when dashboards do not validate against the schema
|
// Show warnings when dashboards do not validate against the schema
|
||||||
FlagShowDashboardValidationWarnings = "showDashboardValidationWarnings"
|
FlagShowDashboardValidationWarnings = "showDashboardValidationWarnings"
|
||||||
|
|
||||||
// FlagMysqlAnsiQuotes
|
|
||||||
// Use double quotes to escape keyword in a MySQL query
|
|
||||||
FlagMysqlAnsiQuotes = "mysqlAnsiQuotes"
|
|
||||||
|
|
||||||
// FlagAlertingBacktesting
|
// FlagAlertingBacktesting
|
||||||
// Rule backtesting API for alerting
|
// Rule backtesting API for alerting
|
||||||
FlagAlertingBacktesting = "alertingBacktesting"
|
FlagAlertingBacktesting = "alertingBacktesting"
|
||||||
|
|||||||
3
pkg/services/featuremgmt/toggles_gen.json
generated
3
pkg/services/featuremgmt/toggles_gen.json
generated
@@ -2302,7 +2302,8 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"name": "mysqlAnsiQuotes",
|
"name": "mysqlAnsiQuotes",
|
||||||
"resourceVersion": "1764664939750",
|
"resourceVersion": "1764664939750",
|
||||||
"creationTimestamp": "2022-10-12T11:43:35Z"
|
"creationTimestamp": "2022-10-12T11:43:35Z",
|
||||||
|
"deletionTimestamp": "2025-12-11T06:46:59Z"
|
||||||
},
|
},
|
||||||
"spec": {
|
"spec": {
|
||||||
"description": "Use double quotes to escape keyword in a MySQL query",
|
"description": "Use double quotes to escape keyword in a MySQL query",
|
||||||
|
|||||||
@@ -166,11 +166,7 @@ func (dbCfg *DatabaseConfig) buildConnectionString(cfg *setting.Cfg, features fe
|
|||||||
cnnstr += fmt.Sprintf("&transaction_isolation=%s", val)
|
cnnstr += fmt.Sprintf("&transaction_isolation=%s", val)
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint:staticcheck // not yet migrated to OpenFeature
|
|
||||||
if features != nil && features.IsEnabledGlobally(featuremgmt.FlagMysqlAnsiQuotes) {
|
|
||||||
cnnstr += "&sql_mode='ANSI_QUOTES'"
|
cnnstr += "&sql_mode='ANSI_QUOTES'"
|
||||||
}
|
|
||||||
|
|
||||||
cnnstr += buildExtraConnectionString('&', dbCfg.UrlQueryParams)
|
cnnstr += buildExtraConnectionString('&', dbCfg.UrlQueryParams)
|
||||||
case migrator.Postgres:
|
case migrator.Postgres:
|
||||||
addr, err := util.SplitHostPortDefault(dbCfg.Host, "127.0.0.1", "5432")
|
addr, err := util.SplitHostPortDefault(dbCfg.Host, "127.0.0.1", "5432")
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ var databaseConfigTestCases = []databaseConfigTest{
|
|||||||
name: "MySQL IPv4",
|
name: "MySQL IPv4",
|
||||||
dbType: "mysql",
|
dbType: "mysql",
|
||||||
dbHost: "1.2.3.4:5678",
|
dbHost: "1.2.3.4:5678",
|
||||||
expConnStr: ":@tcp(1.2.3.4:5678)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true",
|
expConnStr: ":@tcp(1.2.3.4:5678)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Postgres IPv4",
|
name: "Postgres IPv4",
|
||||||
@@ -65,13 +65,13 @@ var databaseConfigTestCases = []databaseConfigTest{
|
|||||||
name: "MySQL IPv4 (Default Port)",
|
name: "MySQL IPv4 (Default Port)",
|
||||||
dbType: "mysql",
|
dbType: "mysql",
|
||||||
dbHost: "1.2.3.4",
|
dbHost: "1.2.3.4",
|
||||||
expConnStr: ":@tcp(1.2.3.4)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true",
|
expConnStr: ":@tcp(1.2.3.4)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "MySQL IPv6",
|
name: "MySQL IPv6",
|
||||||
dbType: "mysql",
|
dbType: "mysql",
|
||||||
dbHost: "[fe80::24e8:31b2:91df:b177]:1234",
|
dbHost: "[fe80::24e8:31b2:91df:b177]:1234",
|
||||||
expConnStr: ":@tcp([fe80::24e8:31b2:91df:b177]:1234)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true",
|
expConnStr: ":@tcp([fe80::24e8:31b2:91df:b177]:1234)/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Postgres IPv6",
|
name: "Postgres IPv6",
|
||||||
@@ -83,7 +83,7 @@ var databaseConfigTestCases = []databaseConfigTest{
|
|||||||
name: "MySQL IPv6 (Default Port)",
|
name: "MySQL IPv6 (Default Port)",
|
||||||
dbType: "mysql",
|
dbType: "mysql",
|
||||||
dbHost: "[::1]",
|
dbHost: "[::1]",
|
||||||
expConnStr: ":@tcp([::1])/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true",
|
expConnStr: ":@tcp([::1])/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Postgres IPv6 (Default Port)",
|
name: "Postgres IPv6 (Default Port)",
|
||||||
@@ -96,13 +96,6 @@ var databaseConfigTestCases = []databaseConfigTest{
|
|||||||
dbURL: "://invalid.com/",
|
dbURL: "://invalid.com/",
|
||||||
err: &url.Error{Op: "parse", URL: "://invalid.com/", Err: errors.New("missing protocol scheme")},
|
err: &url.Error{Op: "parse", URL: "://invalid.com/", Err: errors.New("missing protocol scheme")},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "MySQL with ANSI_QUOTES mode",
|
|
||||||
dbType: "mysql",
|
|
||||||
dbHost: "[::1]",
|
|
||||||
features: featuremgmt.WithFeatures(featuremgmt.FlagMysqlAnsiQuotes),
|
|
||||||
expConnStr: ":@tcp([::1])/test_db?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIntegrationSQLConnectionString(t *testing.T) {
|
func TestIntegrationSQLConnectionString(t *testing.T) {
|
||||||
|
|||||||
@@ -85,19 +85,19 @@ func TestInitEngine_ParseTimeInConnectionString(t *testing.T) {
|
|||||||
name: "MySQL with parseTime already present",
|
name: "MySQL with parseTime already present",
|
||||||
connectionString: "mysql://user:password@localhost:3306/alreadypresent?parseTime=false",
|
connectionString: "mysql://user:password@localhost:3306/alreadypresent?parseTime=false",
|
||||||
dbType: "mysql",
|
dbType: "mysql",
|
||||||
expectedConnection: "user:password@tcp(localhost:3306)/alreadypresent?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&parseTime=false",
|
expectedConnection: "user:password@tcp(localhost:3306)/alreadypresent?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'&parseTime=false",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "MySQL with feature enabled",
|
name: "MySQL with feature enabled",
|
||||||
connectionString: "mysql://user:password@localhost:3306/existingparams?charset=utf8",
|
connectionString: "mysql://user:password@localhost:3306/existingparams?charset=utf8",
|
||||||
dbType: "mysql",
|
dbType: "mysql",
|
||||||
expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&charset=utf8",
|
expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'&charset=utf8",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "MySQL with feature enabled",
|
name: "MySQL with feature enabled",
|
||||||
connectionString: "mysql://user:password@localhost:3306/existingparams?charset=utf8",
|
connectionString: "mysql://user:password@localhost:3306/existingparams?charset=utf8",
|
||||||
dbType: "mysqlWithHooks",
|
dbType: "mysqlWithHooks",
|
||||||
expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&charset=utf8",
|
expectedConnection: "user:password@tcp(localhost:3306)/existingparams?collation=utf8mb4_unicode_ci&allowNativePasswords=true&clientFoundRows=true&parseTime=true&sql_mode='ANSI_QUOTES'&charset=utf8",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Postgres",
|
name: "Postgres",
|
||||||
|
|||||||
Reference in New Issue
Block a user