mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-17 21:08:25 +08:00
fix: Handle empty character set in MariaDB compatibility (#11082)
This commit is contained in:
parent
0a42d4942c
commit
a39dc33770
3 changed files with 12 additions and 5 deletions
|
|
@ -3,6 +3,7 @@ package client
|
|||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"database/sql"
|
||||
"errors"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/agent/global"
|
||||
|
|
@ -82,8 +83,8 @@ type BackupInfo struct {
|
|||
}
|
||||
|
||||
type FormatCollation struct {
|
||||
Format string `json:"format" gorm:"column:CHARACTER_SET_NAME"`
|
||||
Collation string `json:"collation" gorm:"column:COLLATION_NAME"`
|
||||
Format sql.NullString `json:"format" gorm:"column:CHARACTER_SET_NAME"`
|
||||
Collation sql.NullString `json:"collation" gorm:"column:COLLATION_NAME"`
|
||||
}
|
||||
|
||||
type RecoverInfo struct {
|
||||
|
|
|
|||
|
|
@ -405,6 +405,9 @@ func (r *Local) LoadFormatCollation(timeout uint) ([]dto.MysqlFormatCollationOpt
|
|||
if len(parts) != 2 {
|
||||
continue
|
||||
}
|
||||
if parts[0] == "NULL" {
|
||||
continue
|
||||
}
|
||||
if _, ok := formatMap[parts[0]]; !ok {
|
||||
formatMap[parts[0]] = []string{parts[1]}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -421,10 +421,13 @@ func (r *Remote) LoadFormatCollation(timeout uint) ([]dto.MysqlFormatCollationOp
|
|||
if err := rows.Scan(&item.Format, &item.Collation); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, ok := formatMap[item.Format]; !ok {
|
||||
formatMap[item.Format] = []string{item.Collation}
|
||||
if !item.Format.Valid {
|
||||
continue
|
||||
}
|
||||
if _, ok := formatMap[item.Format.String]; !ok {
|
||||
formatMap[item.Format.String] = []string{item.Collation.String}
|
||||
} else {
|
||||
formatMap[item.Format] = append(formatMap[item.Format], item.Collation)
|
||||
formatMap[item.Format.String] = append(formatMap[item.Format.String], item.Collation.String)
|
||||
}
|
||||
}
|
||||
options := []dto.MysqlFormatCollationOption{}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue