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.

118 lines
4.9 KiB

  1. #ifndef S3_FUNC_INCLUDED
  2. #define S3_FUNC_INCLUDED
  3. /* Copyright (C) 2019 MariaDB Corporation Ab
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; version 2 of the License.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software Foundation,
  13. Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
  14. /*
  15. Interface function used by S3 storage engine and aria_copy_for_s3
  16. */
  17. #ifdef WITH_S3_STORAGE_ENGINE
  18. C_MODE_START
  19. #include <libmarias3/marias3.h>
  20. #define DEFAULT_AWS_HOST_NAME "s3.amazonaws.com"
  21. extern TYPELIB s3_protocol_typelib;
  22. /* Store information about a s3 connection */
  23. typedef struct s3_info
  24. {
  25. LEX_CSTRING access_key, secret_key, region, bucket, host_name;
  26. /* The following will be filled in by maria_open() */
  27. LEX_CSTRING database, table;
  28. /* Sent to open to verify version */
  29. LEX_CUSTRING tabledef_version;
  30. /* Protocol for the list bucket API call. 1 for Amazon, 2 for some others */
  31. uint8_t protocol_version;
  32. } S3_INFO;
  33. /* flag + length is stored in this header */
  34. #define COMPRESS_HEADER 4
  35. /* Max length of an AWS PATH */
  36. #define AWS_PATH_LENGTH ((NAME_LEN)*3+3+10+6+11)
  37. void s3_init_library(void);
  38. void s3_deinit_library(void);
  39. int aria_copy_to_s3(ms3_st *s3_client, const char *aws_bucket,
  40. const char *path,
  41. const char *database, const char *table_name,
  42. ulong block_size, my_bool compression,
  43. my_bool force, my_bool display, my_bool copy_frm);
  44. int aria_copy_from_s3(ms3_st *s3_client, const char *aws_bucket,
  45. const char *path,const char *database,
  46. my_bool compression, my_bool force, my_bool display);
  47. int aria_delete_from_s3(ms3_st *s3_client, const char *aws_bucket,
  48. const char *database, const char *table,
  49. my_bool display);
  50. int aria_rename_s3(ms3_st *s3_client, const char *aws_bucket,
  51. const char *from_database, const char *from_table,
  52. const char *to_database, const char *to_table,
  53. my_bool rename_frm);
  54. ms3_st *s3_open_connection(S3_INFO *s3);
  55. my_bool s3_put_object(ms3_st *s3_client, const char *aws_bucket,
  56. const char *name, uchar *data, size_t length,
  57. my_bool compression);
  58. my_bool s3_get_object(ms3_st *s3_client, const char *aws_bucket,
  59. const char *name, S3_BLOCK *block, my_bool compression,
  60. my_bool print_error);
  61. my_bool s3_delete_object(ms3_st *s3_client, const char *aws_bucket,
  62. const char *name, my_bool print_error);
  63. my_bool s3_rename_object(ms3_st *s3_client, const char *aws_bucket,
  64. const char *from_name, const char *to_name,
  65. my_bool print_error);
  66. void s3_free(S3_BLOCK *data);
  67. my_bool s3_copy_from_file(ms3_st *s3_client, const char *aws_bucket,
  68. char *aws_path, File file, my_off_t start,
  69. my_off_t file_end, uchar *block, size_t block_size,
  70. my_bool compression, my_bool display);
  71. my_bool s3_copy_to_file(ms3_st *s3_client, const char *aws_bucket,
  72. char *aws_path, File file, my_off_t start,
  73. my_off_t file_end, my_bool compression,
  74. my_bool display);
  75. int s3_delete_directory(ms3_st *s3_client, const char *aws_bucket,
  76. const char *path);
  77. int s3_rename_directory(ms3_st *s3_client, const char *aws_bucket,
  78. const char *from_name, const char *to_name,
  79. my_bool print_error);
  80. S3_INFO *s3_info_copy(S3_INFO *old);
  81. my_bool set_database_and_table_from_path(S3_INFO *s3, const char *path);
  82. my_bool s3_get_frm(ms3_st *s3_client, S3_INFO *S3_info, S3_BLOCK *block);
  83. my_bool s3_frm_exists(ms3_st *s3_client, S3_INFO *s3_info);
  84. int s3_check_frm_version(ms3_st *s3_client, S3_INFO *s3_info);
  85. my_bool read_index_header(ms3_st *client, S3_INFO *s3, S3_BLOCK *block);
  86. int32 s3_unique_file_number(void);
  87. my_bool s3_block_read(struct st_pagecache *pagecache,
  88. PAGECACHE_IO_HOOK_ARGS *args,
  89. struct st_pagecache_file *file,
  90. S3_BLOCK *block);
  91. C_MODE_END
  92. #else
  93. C_MODE_START
  94. /* Dummy structures and interfaces to be used when compiling without S3 */
  95. struct s3_info;
  96. typedef struct s3_info S3_INFO;
  97. struct ms3_st;
  98. C_MODE_END
  99. #endif /* WITH_S3_STORAGE_ENGINE */
  100. #endif /* HA_S3_FUNC_INCLUDED */