seaweedfs/weed/filer/ydb/ydb_queries.go

86 lines
2.2 KiB
Go
Raw Normal View History

2022-05-05 06:12:14 +00:00
//go:build ydb
// +build ydb
2022-05-01 15:33:03 +00:00
package ydb
2022-05-02 07:42:20 +00:00
import asql "github.com/chrislusf/seaweedfs/weed/filer/abstract_sql"
2022-05-01 15:33:03 +00:00
2022-05-02 07:42:20 +00:00
const (
2022-05-01 15:33:03 +00:00
insertQuery = `
2022-05-03 15:16:00 +00:00
PRAGMA TablePathPrefix("%v");
2022-05-02 19:11:37 +00:00
DECLARE $dir_hash AS int64;
2022-05-01 15:33:03 +00:00
DECLARE $directory AS Utf8;
2022-05-03 10:18:28 +00:00
DECLARE $name AS Utf8;
2022-05-01 15:33:03 +00:00
DECLARE $meta AS String;
2022-05-03 12:52:23 +00:00
DECLARE $expire_at AS Optional<uint32>;
2022-05-01 15:33:03 +00:00
2022-05-02 07:42:20 +00:00
UPSERT INTO ` + asql.DEFAULT_TABLE + `
2022-05-03 12:52:23 +00:00
(dir_hash, name, directory, meta, expire_at)
2022-05-01 15:33:03 +00:00
VALUES
2022-05-03 12:52:23 +00:00
($dir_hash, $name, $directory, $meta, $expire_at);`
2022-05-01 15:33:03 +00:00
updateQuery = `
2022-05-03 15:16:00 +00:00
PRAGMA TablePathPrefix("%v");
2022-05-02 19:11:37 +00:00
DECLARE $dir_hash AS int64;
2022-05-01 15:33:03 +00:00
DECLARE $directory AS Utf8;
2022-05-03 10:18:28 +00:00
DECLARE $name AS Utf8;
2022-05-01 15:33:03 +00:00
DECLARE $meta AS String;
2022-05-03 12:52:23 +00:00
DECLARE $expire_at AS Optional<uint32>;
2022-05-01 15:33:03 +00:00
2022-05-02 07:42:20 +00:00
REPLACE INTO ` + asql.DEFAULT_TABLE + `
2022-05-03 12:52:23 +00:00
(dir_hash, name, directory, meta, expire_at)
2022-05-01 15:33:03 +00:00
VALUES
2022-05-03 12:52:23 +00:00
($dir_hash, $name, $directory, $meta, $expire_at);`
2022-05-01 15:33:03 +00:00
deleteQuery = `
2022-05-03 15:16:00 +00:00
PRAGMA TablePathPrefix("%v");
2022-05-02 19:11:37 +00:00
DECLARE $dir_hash AS int64;
2022-05-01 15:33:03 +00:00
DECLARE $name AS Utf8;
2022-05-02 07:42:20 +00:00
DELETE FROM ` + asql.DEFAULT_TABLE + `
WHERE dir_hash = $dir_hash AND name = $name;`
2022-05-01 15:33:03 +00:00
findQuery = `
2022-05-03 15:16:00 +00:00
PRAGMA TablePathPrefix("%v");
2022-05-02 19:11:37 +00:00
DECLARE $dir_hash AS int64;
2022-05-01 15:33:03 +00:00
DECLARE $name AS Utf8;
SELECT meta
2022-05-02 19:11:37 +00:00
FROM ` + asql.DEFAULT_TABLE + `
2022-05-03 10:18:28 +00:00
WHERE dir_hash = $dir_hash AND name = $name;`
2022-05-01 15:33:03 +00:00
deleteFolderChildrenQuery = `
2022-05-03 15:16:00 +00:00
PRAGMA TablePathPrefix("%v");
2022-05-02 19:11:37 +00:00
DECLARE $dir_hash AS int64;
2022-05-01 15:33:03 +00:00
DECLARE $directory AS Utf8;
2022-05-02 07:42:20 +00:00
DELETE FROM ` + asql.DEFAULT_TABLE + `
WHERE dir_hash = $dir_hash AND directory = $directory;`
2022-05-01 15:33:03 +00:00
2022-05-02 07:42:20 +00:00
listDirectoryQuery = `
2022-05-03 15:16:00 +00:00
PRAGMA TablePathPrefix("%v");
2022-05-02 19:11:37 +00:00
DECLARE $dir_hash AS int64;
2022-05-01 15:33:03 +00:00
DECLARE $directory AS Utf8;
DECLARE $start_name AS Utf8;
DECLARE $prefix AS Utf8;
2022-05-02 19:11:37 +00:00
DECLARE $limit AS Uint64;
2022-05-01 15:33:03 +00:00
SELECT name, meta
2022-05-02 07:42:20 +00:00
FROM ` + asql.DEFAULT_TABLE + `
2022-05-03 15:16:00 +00:00
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
2022-05-01 15:33:03 +00:00
ORDER BY name ASC LIMIT $limit;`
)