aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/postgres2/postgres2_store.go
diff options
context:
space:
mode:
authorhilimd <68371223+hilimd@users.noreply.github.com>2021-04-06 13:39:26 +0800
committerGitHub <noreply@github.com>2021-04-06 13:39:26 +0800
commit8693cdacae5b4201ccd259382a02392250b0890e (patch)
treeb565af4380b0f59a61b1d3c9fad8f04cbb802e7c /weed/filer/postgres2/postgres2_store.go
parent17d02264f33f501e124060ade7b0b39e687aaa3d (diff)
parenta37eca78cd680858d021cd864766b0847328a8d7 (diff)
downloadseaweedfs-8693cdacae5b4201ccd259382a02392250b0890e.tar.xz
seaweedfs-8693cdacae5b4201ccd259382a02392250b0890e.zip
Merge pull request #75 from chrislusf/master
sync
Diffstat (limited to 'weed/filer/postgres2/postgres2_store.go')
-rw-r--r--weed/filer/postgres2/postgres2_store.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/weed/filer/postgres2/postgres2_store.go b/weed/filer/postgres2/postgres2_store.go
index 92893bf7a..0f573d8d0 100644
--- a/weed/filer/postgres2/postgres2_store.go
+++ b/weed/filer/postgres2/postgres2_store.go
@@ -32,6 +32,8 @@ func (store *PostgresStore2) GetName() string {
func (store *PostgresStore2) Initialize(configuration util.Configuration, prefix string) (err error) {
return store.initialize(
configuration.GetString(prefix+"createTable"),
+ configuration.GetString(prefix+"upsertQuery"),
+ configuration.GetBool(prefix+"enableUpsert"),
configuration.GetString(prefix+"username"),
configuration.GetString(prefix+"password"),
configuration.GetString(prefix+"hostname"),
@@ -45,12 +47,16 @@ func (store *PostgresStore2) Initialize(configuration util.Configuration, prefix
)
}
-func (store *PostgresStore2) initialize(createTable, user, password, hostname string, port int, database, schema, sslmode string, maxIdle, maxOpen, maxLifetimeSeconds int) (err error) {
+func (store *PostgresStore2) initialize(createTable, upsertQuery string, enableUpsert bool, user, password, hostname string, port int, database, schema, sslmode string, maxIdle, maxOpen, maxLifetimeSeconds int) (err error) {
store.SupportBucketTable = true
+ if !enableUpsert {
+ upsertQuery = ""
+ }
store.SqlGenerator = &postgres.SqlGenPostgres{
CreateTableSqlTemplate: createTable,
DropTableSqlTemplate: `drop table "%s"`,
+ UpsertQueryTemplate: upsertQuery,
}
sqlUrl := fmt.Sprintf(CONNECTION_URL_PATTERN, hostname, port, sslmode)