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.

64 lines
1.5 KiB

  1. package ydb
  2. import asql "github.com/chrislusf/seaweedfs/weed/filer/abstract_sql"
  3. const (
  4. insertQuery = `
  5. DECLARE $dir_hash int64;
  6. DECLARE $name AS Utf8;
  7. DECLARE $directory AS Utf8;
  8. DECLARE $meta AS String;
  9. UPSERT INTO ` + asql.DEFAULT_TABLE + `
  10. (dir_hash, name, directory, meta)
  11. VALUES
  12. ($dir_hash, $name, $directory, $meta);`
  13. updateQuery = `
  14. DECLARE $dir_hash int64;
  15. DECLARE $name AS Utf8;
  16. DECLARE $directory AS Utf8;
  17. DECLARE $meta AS String;
  18. REPLACE INTO ` + asql.DEFAULT_TABLE + `
  19. (dir_hash, name, directory, meta)
  20. VALUES
  21. ($dir_hash, $name, $directory, $meta)
  22. COMMIT;`
  23. deleteQuery = `
  24. DECLARE $dir_hash int64;
  25. DECLARE $name AS Utf8;
  26. DELETE FROM ` + asql.DEFAULT_TABLE + `
  27. WHERE dir_hash == $dir_hash AND name == $name;
  28. COMMIT;`
  29. findQuery = `
  30. DECLARE $dir_hash int64;
  31. DECLARE $name AS Utf8;
  32. SELECT meta
  33. FROM file_meta
  34. WHERE dir_hash == $dir_hash AND name == $name;`
  35. deleteFolderChildrenQuery = `
  36. DECLARE $dir_hash int64;
  37. DECLARE $directory AS Utf8;
  38. DELETE FROM ` + asql.DEFAULT_TABLE + `
  39. WHERE dir_hash == $dir_hash AND directory == $directory;
  40. COMMIT;`
  41. listDirectoryQuery = `
  42. DECLARE $dir_hash int64;
  43. DECLARE $directory AS Utf8;
  44. DECLARE $start_name AS Utf8;
  45. DECLARE $prefix AS Utf8;
  46. DECLARE $limit AS int64;
  47. SELECT name, meta
  48. FROM ` + asql.DEFAULT_TABLE + `
  49. WHERE dir_hash == $dir_hash AND directory == $directory and name %s $start_name and name LIKE '$prefix%%'
  50. ORDER BY name ASC LIMIT $limit;`
  51. )