Added options s3_port and s3_use_http to aria_s3_copy

These options was needed in some cases, like when using minio that require
the port option, to be able to connect to the S3 storage.
The sympthom was that one could get the error
"Table t1.MAI doesn't exist in s3"
even if the table did exits.

Other things:
- Improved error message for non existing S3 files
This commit is contained in:
Monty 2021-08-31 15:34:28 +03:00
parent 1fcd8db776
commit 6bdc03ebcc
2 changed files with 25 additions and 9 deletions

View File

@ -40,8 +40,10 @@ static const char *opt_s3_host_name= DEFAULT_AWS_HOST_NAME;
static const char *opt_database; static const char *opt_database;
static const char *opt_s3_bucket="MariaDB"; static const char *opt_s3_bucket="MariaDB";
static my_bool opt_compression, opt_verbose, opt_force, opt_s3_debug; static my_bool opt_compression, opt_verbose, opt_force, opt_s3_debug;
static my_bool opt_s3_use_http;
static ulong opt_operation= OP_IMPOSSIBLE, opt_protocol_version= 1; static ulong opt_operation= OP_IMPOSSIBLE, opt_protocol_version= 1;
static ulong opt_block_size; static ulong opt_block_size;
static ulong opt_s3_port;
static char **default_argv=0; static char **default_argv=0;
static ms3_st *global_s3_client= 0; static ms3_st *global_s3_client= 0;
@ -65,6 +67,12 @@ static struct my_option my_long_options[] =
{"s3_host_name", 'h', "Host name to S3 provider", {"s3_host_name", 'h', "Host name to S3 provider",
(char**) &opt_s3_host_name, (char**) &opt_s3_host_name, 0, (char**) &opt_s3_host_name, (char**) &opt_s3_host_name, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"s3_port", 'p', "Port number to connect to (0 means use default)",
(char**) &opt_s3_port, (char**) &opt_s3_port, 0, GET_ULONG, REQUIRED_ARG,
0, 0, 65536, 0, 1, 0 },
{"s3_use_http", 'P', "If true, force use of HTTP protocol",
(char**) &opt_s3_use_http, (char**) &opt_s3_use_http,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"compress", 'c', "Use compression", &opt_compression, &opt_compression, {"compress", 'c', "Use compression", &opt_compression, &opt_compression,
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"op", 'o', "Operation to execute. One of 'from_s3', 'to_s3' or " {"op", 'o', "Operation to execute. One of 'from_s3', 'to_s3' or "
@ -196,6 +204,7 @@ int main(int argc, char** argv)
{ {
MY_INIT(argv[0]); MY_INIT(argv[0]);
get_options(&argc,(char***) &argv); get_options(&argc,(char***) &argv);
size_t block_size= opt_block_size;
s3_init_library(); s3_init_library();
if (!(global_s3_client= ms3_init(opt_s3_access_key, if (!(global_s3_client= ms3_init(opt_s3_access_key,
@ -207,15 +216,22 @@ int main(int argc, char** argv)
my_exit(1); my_exit(1);
} }
{ ms3_set_option(global_s3_client, MS3_OPT_BUFFER_CHUNK_SIZE, &block_size);
size_t block_size= opt_block_size;
uint8_t protocol_version= (uint8_t) opt_protocol_version;
ms3_set_option(global_s3_client, MS3_OPT_BUFFER_CHUNK_SIZE, &block_size);
if (protocol_version) if (opt_protocol_version)
ms3_set_option(global_s3_client, MS3_OPT_FORCE_PROTOCOL_VERSION, {
&protocol_version); uint8_t protocol_version= (uint8_t) opt_protocol_version;
ms3_set_option(global_s3_client, MS3_OPT_FORCE_PROTOCOL_VERSION,
&protocol_version);
} }
if (opt_s3_port)
{
int port= (int) opt_s3_port;
ms3_set_option(global_s3_client, MS3_OPT_PORT_NUMBER, &port);
}
if (opt_s3_use_http)
ms3_set_option(global_s3_client, MS3_OPT_USE_HTTP, NULL);
for (; *argv ; argv++) for (; *argv ; argv++)
{ {

View File

@ -583,8 +583,8 @@ int aria_copy_from_s3(ms3_st *s3_client, const char *aws_bucket,
if (s3_get_object(s3_client, aws_bucket, aws_path, &block, 0, 0)) if (s3_get_object(s3_client, aws_bucket, aws_path, &block, 0, 0))
{ {
my_printf_error(EE_FILENOTFOUND, "Table %s doesn't exist in s3", MYF(0), my_printf_error(EE_FILENOTFOUND, "File %s/%s doesn't exist in s3", MYF(0),
filename); database,filename);
goto err; goto err;
} }
if (block.length < MARIA_STATE_INFO_SIZE) if (block.length < MARIA_STATE_INFO_SIZE)