Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

Update filer upsert sqlstring for postgresql (#6835)

Luna Yao5e354a18a3d7
diff --git a/weed/command/scaffold/filer.toml b/weed/command/scaffold/filer.toml
index e9f140576a..24aeacef3d 100644
--- a/weed/command/scaffold/filer.toml
+++ b/weed/command/scaffold/filer.toml
@@ -116,7 +116,13 @@ connection_max_open = 100
connection_max_lifetime_seconds = 0
# if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax:
enableUpsert = true
-upsertQuery = """UPSERT INTO "%[1]s" (dirhash,name,directory,meta) VALUES($1,$2,$3,$4)"""
+upsertQuery = """
+ INSERT INTO "%[1]s" (dirhash, name, directory, meta)
+ VALUES($1, $2, $3, $4)
+ ON CONFLICT (dirhash, name) DO UPDATE SET
+ directory=EXCLUDED.directory,
+ meta=EXCLUDED.meta
+"""
[postgres2]
enabled = false
@@ -141,7 +147,13 @@ connection_max_open = 100
connection_max_lifetime_seconds = 0
# if insert/upsert failing, you can disable upsert or update query syntax to match your RDBMS syntax:
enableUpsert = true
-upsertQuery = """UPSERT INTO "%[1]s" (dirhash,name,directory,meta) VALUES($1,$2,$3,$4)"""
+upsertQuery = """
+ INSERT INTO "%[1]s" (dirhash, name, directory, meta)
+ VALUES($1, $2, $3, $4)
+ ON CONFLICT (dirhash, name) DO UPDATE SET
+ directory=EXCLUDED.directory,
+ meta=EXCLUDED.meta
+"""
[cassandra2]
# CREATE TABLE filemeta (