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