ydb_queries.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //go:build ydb
  2. // +build ydb
  3. package ydb
  4. import asql "github.com/seaweedfs/seaweedfs/weed/filer/abstract_sql"
  5. const (
  6. upsertQuery = `
  7. PRAGMA TablePathPrefix("%v");
  8. DECLARE $dir_hash AS int64;
  9. DECLARE $directory AS Utf8;
  10. DECLARE $name AS Utf8;
  11. DECLARE $meta AS String;
  12. DECLARE $expire_at AS Optional<uint32>;
  13. UPSERT INTO ` + asql.DEFAULT_TABLE + `
  14. (dir_hash, name, directory, meta, expire_at)
  15. VALUES
  16. ($dir_hash, $name, $directory, $meta, $expire_at);`
  17. deleteQuery = `
  18. PRAGMA TablePathPrefix("%v");
  19. DECLARE $dir_hash AS int64;
  20. DECLARE $name AS Utf8;
  21. DELETE FROM ` + asql.DEFAULT_TABLE + `
  22. WHERE dir_hash = $dir_hash AND name = $name;`
  23. findQuery = `
  24. PRAGMA TablePathPrefix("%v");
  25. DECLARE $dir_hash AS int64;
  26. DECLARE $name AS Utf8;
  27. SELECT meta
  28. FROM ` + asql.DEFAULT_TABLE + `
  29. WHERE dir_hash = $dir_hash AND name = $name;`
  30. deleteFolderChildrenQuery = `
  31. PRAGMA TablePathPrefix("%v");
  32. DECLARE $dir_hash AS int64;
  33. DECLARE $directory AS Utf8;
  34. DELETE FROM ` + asql.DEFAULT_TABLE + `
  35. WHERE dir_hash = $dir_hash AND directory = $directory;`
  36. listDirectoryQuery = `
  37. PRAGMA TablePathPrefix("%v");
  38. DECLARE $dir_hash AS int64;
  39. DECLARE $directory AS Utf8;
  40. DECLARE $start_name AS Utf8;
  41. DECLARE $prefix AS Utf8;
  42. DECLARE $limit AS Uint64;
  43. SELECT name, meta
  44. FROM ` + asql.DEFAULT_TABLE + `
  45. WHERE dir_hash = $dir_hash AND directory = $directory and name > $start_name and name LIKE $prefix
  46. ORDER BY name ASC LIMIT $limit;`
  47. listInclusiveDirectoryQuery = `
  48. PRAGMA TablePathPrefix("%v");
  49. DECLARE $dir_hash AS int64;
  50. DECLARE $directory AS Utf8;
  51. DECLARE $start_name AS Utf8;
  52. DECLARE $prefix AS Utf8;
  53. DECLARE $limit AS Uint64;
  54. SELECT name, meta
  55. FROM ` + asql.DEFAULT_TABLE + `
  56. WHERE dir_hash = $dir_hash AND directory = $directory and name >= $start_name and name LIKE $prefix
  57. ORDER BY name ASC LIMIT $limit;`
  58. )