You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.2 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. //go:build ydb
  2. // +build ydb
  3. package ydb
  4. import asql "github.com/chrislusf/seaweedfs/weed/filer/abstract_sql"
  5. const (
  6. insertQuery = `
  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. updateQuery = `
  18. PRAGMA TablePathPrefix("%v");
  19. DECLARE $dir_hash AS int64;
  20. DECLARE $directory AS Utf8;
  21. DECLARE $name AS Utf8;
  22. DECLARE $meta AS String;
  23. DECLARE $expire_at AS Optional<uint32>;
  24. REPLACE INTO ` + asql.DEFAULT_TABLE + `
  25. (dir_hash, name, directory, meta, expire_at)
  26. VALUES
  27. ($dir_hash, $name, $directory, $meta, $expire_at);`
  28. deleteQuery = `
  29. PRAGMA TablePathPrefix("%v");
  30. DECLARE $dir_hash AS int64;
  31. DECLARE $name AS Utf8;
  32. DELETE FROM ` + asql.DEFAULT_TABLE + `
  33. WHERE dir_hash = $dir_hash AND name = $name;`
  34. findQuery = `
  35. PRAGMA TablePathPrefix("%v");
  36. DECLARE $dir_hash AS int64;
  37. DECLARE $name AS Utf8;
  38. SELECT meta
  39. FROM ` + asql.DEFAULT_TABLE + `
  40. WHERE dir_hash = $dir_hash AND name = $name;`
  41. deleteFolderChildrenQuery = `
  42. PRAGMA TablePathPrefix("%v");
  43. DECLARE $dir_hash AS int64;
  44. DECLARE $directory AS Utf8;
  45. DELETE FROM ` + asql.DEFAULT_TABLE + `
  46. WHERE dir_hash = $dir_hash AND directory = $directory;`
  47. listDirectoryQuery = `
  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. listInclusiveDirectoryQuery = `
  59. PRAGMA TablePathPrefix("%v");
  60. DECLARE $dir_hash AS int64;
  61. DECLARE $directory AS Utf8;
  62. DECLARE $start_name AS Utf8;
  63. DECLARE $prefix AS Utf8;
  64. DECLARE $limit AS Uint64;
  65. SELECT name, meta
  66. FROM ` + asql.DEFAULT_TABLE + `
  67. WHERE dir_hash = $dir_hash AND directory = $directory and name >= $start_name and name LIKE $prefix
  68. ORDER BY name ASC LIMIT $limit;`
  69. )