aboutsummaryrefslogtreecommitdiff
path: root/weed/filer/ydb/ydb_queries.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2022-05-06 01:51:28 -0700
committerchrislu <chris.lu@gmail.com>2022-05-06 01:51:28 -0700
commitb2a43dd044123d244be26c87155187d211be1c49 (patch)
tree7dc5edc901f204b2da91f245eb44abae1b04df29 /weed/filer/ydb/ydb_queries.go
parentd5fe5d12b74d65a65138de62e9d98cfb3bac14de (diff)
parenta69bf53405d703f29f7b8ca358c67840c2876499 (diff)
downloadseaweedfs-b2a43dd044123d244be26c87155187d211be1c49.tar.xz
seaweedfs-b2a43dd044123d244be26c87155187d211be1c49.zip
Merge branch 'master' of https://github.com/chrislusf/seaweedfs
Diffstat (limited to 'weed/filer/ydb/ydb_queries.go')
-rw-r--r--weed/filer/ydb/ydb_queries.go85
1 files changed, 85 insertions, 0 deletions
diff --git a/weed/filer/ydb/ydb_queries.go b/weed/filer/ydb/ydb_queries.go
new file mode 100644
index 000000000..c8876e004
--- /dev/null
+++ b/weed/filer/ydb/ydb_queries.go
@@ -0,0 +1,85 @@
+//go:build ydb
+// +build ydb
+
+package ydb
+
+import asql "github.com/chrislusf/seaweedfs/weed/filer/abstract_sql"
+
+const (
+ insertQuery = `
+ PRAGMA TablePathPrefix("%v");
+ DECLARE $dir_hash AS int64;
+ DECLARE $directory AS Utf8;
+ DECLARE $name AS Utf8;
+ DECLARE $meta AS String;
+ DECLARE $expire_at AS Optional<uint32>;
+
+ UPSERT INTO ` + asql.DEFAULT_TABLE + `
+ (dir_hash, name, directory, meta, expire_at)
+ VALUES
+ ($dir_hash, $name, $directory, $meta, $expire_at);`
+
+ updateQuery = `
+ PRAGMA TablePathPrefix("%v");
+ DECLARE $dir_hash AS int64;
+ DECLARE $directory AS Utf8;
+ DECLARE $name AS Utf8;
+ DECLARE $meta AS String;
+ DECLARE $expire_at AS Optional<uint32>;
+
+ REPLACE INTO ` + asql.DEFAULT_TABLE + `
+ (dir_hash, name, directory, meta, expire_at)
+ VALUES
+ ($dir_hash, $name, $directory, $meta, $expire_at);`
+
+ deleteQuery = `
+ PRAGMA TablePathPrefix("%v");
+ DECLARE $dir_hash AS int64;
+ DECLARE $name AS Utf8;
+
+ DELETE FROM ` + asql.DEFAULT_TABLE + `
+ WHERE dir_hash = $dir_hash AND name = $name;`
+
+ findQuery = `
+ PRAGMA TablePathPrefix("%v");
+ DECLARE $dir_hash AS int64;
+ DECLARE $name AS Utf8;
+
+ SELECT meta
+ FROM ` + asql.DEFAULT_TABLE + `
+ WHERE dir_hash = $dir_hash AND name = $name;`
+
+ deleteFolderChildrenQuery = `
+ PRAGMA TablePathPrefix("%v");
+ DECLARE $dir_hash AS int64;
+ DECLARE $directory AS Utf8;
+
+ DELETE FROM ` + asql.DEFAULT_TABLE + `
+ WHERE dir_hash = $dir_hash AND directory = $directory;`
+
+ listDirectoryQuery = `
+ PRAGMA TablePathPrefix("%v");
+ DECLARE $dir_hash AS int64;
+ DECLARE $directory AS Utf8;
+ DECLARE $start_name AS Utf8;
+ DECLARE $prefix AS Utf8;
+ DECLARE $limit AS Uint64;
+
+ SELECT name, meta
+ FROM ` + asql.DEFAULT_TABLE + `
+ WHERE dir_hash = $dir_hash AND directory = $directory and name > $start_name and name LIKE $prefix
+ ORDER BY name ASC LIMIT $limit;`
+
+ listInclusiveDirectoryQuery = `
+ PRAGMA TablePathPrefix("%v");
+ DECLARE $dir_hash AS int64;
+ DECLARE $directory AS Utf8;
+ DECLARE $start_name AS Utf8;
+ DECLARE $prefix AS Utf8;
+ DECLARE $limit AS Uint64;
+
+ SELECT name, meta
+ FROM ` + asql.DEFAULT_TABLE + `
+ WHERE dir_hash = $dir_hash AND directory = $directory and name >= $start_name and name LIKE $prefix
+ ORDER BY name ASC LIMIT $limit;`
+)