mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
filer: support memsql
fix https://github.com/chrislusf/seaweedfs/issues/1141
This commit is contained in:
parent
0f9ba84274
commit
46294b42e6
|
@ -95,6 +95,7 @@ password = ""
|
||||||
database = "" # create or use an existing database
|
database = "" # create or use an existing database
|
||||||
connection_max_idle = 2
|
connection_max_idle = 2
|
||||||
connection_max_open = 100
|
connection_max_open = 100
|
||||||
|
interpolateParams = false
|
||||||
|
|
||||||
[postgres] # or cockroachdb
|
[postgres] # or cockroachdb
|
||||||
# CREATE TABLE IF NOT EXISTS filemeta (
|
# CREATE TABLE IF NOT EXISTS filemeta (
|
||||||
|
|
|
@ -35,10 +35,12 @@ func (store *MysqlStore) Initialize(configuration util.Configuration) (err error
|
||||||
configuration.GetString("database"),
|
configuration.GetString("database"),
|
||||||
configuration.GetInt("connection_max_idle"),
|
configuration.GetInt("connection_max_idle"),
|
||||||
configuration.GetInt("connection_max_open"),
|
configuration.GetInt("connection_max_open"),
|
||||||
|
configuration.GetBool("interpolateParams"),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *MysqlStore) initialize(user, password, hostname string, port int, database string, maxIdle, maxOpen int) (err error) {
|
func (store *MysqlStore) initialize(user, password, hostname string, port int, database string, maxIdle, maxOpen int,
|
||||||
|
interpolateParams bool) (err error) {
|
||||||
|
|
||||||
store.SqlInsert = "INSERT INTO filemeta (dirhash,name,directory,meta) VALUES(?,?,?,?)"
|
store.SqlInsert = "INSERT INTO filemeta (dirhash,name,directory,meta) VALUES(?,?,?,?)"
|
||||||
store.SqlUpdate = "UPDATE filemeta SET meta=? WHERE dirhash=? AND name=? AND directory=?"
|
store.SqlUpdate = "UPDATE filemeta SET meta=? WHERE dirhash=? AND name=? AND directory=?"
|
||||||
|
@ -48,6 +50,10 @@ func (store *MysqlStore) initialize(user, password, hostname string, port int, d
|
||||||
store.SqlListInclusive = "SELECT NAME, meta FROM filemeta WHERE dirhash=? AND name>=? AND directory=? ORDER BY NAME ASC LIMIT ?"
|
store.SqlListInclusive = "SELECT NAME, meta FROM filemeta WHERE dirhash=? AND name>=? AND directory=? ORDER BY NAME ASC LIMIT ?"
|
||||||
|
|
||||||
sqlUrl := fmt.Sprintf(CONNECTION_URL_PATTERN, user, password, hostname, port, database)
|
sqlUrl := fmt.Sprintf(CONNECTION_URL_PATTERN, user, password, hostname, port, database)
|
||||||
|
if interpolateParams {
|
||||||
|
sqlUrl += "&interpolateParams=true"
|
||||||
|
}
|
||||||
|
|
||||||
var dbErr error
|
var dbErr error
|
||||||
store.DB, dbErr = sql.Open("mysql", sqlUrl)
|
store.DB, dbErr = sql.Open("mysql", sqlUrl)
|
||||||
if dbErr != nil {
|
if dbErr != nil {
|
||||||
|
|
Loading…
Reference in a new issue