parseDSNParams parses the DSN "query string" Values must be url.QueryEscape'ed
(cfg *Config, params string)
| 476 | // parseDSNParams parses the DSN "query string" |
| 477 | // Values must be url.QueryEscape'ed |
| 478 | func parseDSNParams(cfg *Config, params string) (err error) { |
| 479 | for v := range strings.SplitSeq(params, "&") { |
| 480 | key, value, found := strings.Cut(v, "=") |
| 481 | if !found { |
| 482 | continue |
| 483 | } |
| 484 | |
| 485 | // cfg params |
| 486 | switch key { |
| 487 | // Disable INFILE allowlist / enable all files |
| 488 | case "allowAllFiles": |
| 489 | var isBool bool |
| 490 | cfg.AllowAllFiles, isBool = readBool(value) |
| 491 | if !isBool { |
| 492 | return errors.New("invalid bool value: " + value) |
| 493 | } |
| 494 | |
| 495 | // Use cleartext authentication mode (MySQL 5.5.10+) |
| 496 | case "allowCleartextPasswords": |
| 497 | var isBool bool |
| 498 | cfg.AllowCleartextPasswords, isBool = readBool(value) |
| 499 | if !isBool { |
| 500 | return errors.New("invalid bool value: " + value) |
| 501 | } |
| 502 | |
| 503 | // Allow fallback to unencrypted connection if server does not support TLS |
| 504 | case "allowFallbackToPlaintext": |
| 505 | var isBool bool |
| 506 | cfg.AllowFallbackToPlaintext, isBool = readBool(value) |
| 507 | if !isBool { |
| 508 | return errors.New("invalid bool value: " + value) |
| 509 | } |
| 510 | |
| 511 | // Use native password authentication |
| 512 | case "allowNativePasswords": |
| 513 | var isBool bool |
| 514 | cfg.AllowNativePasswords, isBool = readBool(value) |
| 515 | if !isBool { |
| 516 | return errors.New("invalid bool value: " + value) |
| 517 | } |
| 518 | |
| 519 | // Use old authentication mode (pre MySQL 4.1) |
| 520 | case "allowOldPasswords": |
| 521 | var isBool bool |
| 522 | cfg.AllowOldPasswords, isBool = readBool(value) |
| 523 | if !isBool { |
| 524 | return errors.New("invalid bool value: " + value) |
| 525 | } |
| 526 | |
| 527 | // Check connections for Liveness before using them |
| 528 | case "checkConnLiveness": |
| 529 | var isBool bool |
| 530 | cfg.CheckConnLiveness, isBool = readBool(value) |
| 531 | if !isBool { |
| 532 | return errors.New("invalid bool value: " + value) |
| 533 | } |
| 534 | |
| 535 | // Switch "rowsAffected" mode |