Skip to content

Commit 6bdc03e

Browse files
committed
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
1 parent 1fcd8db commit 6bdc03e

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

storage/maria/aria_s3_copy.cc

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ static const char *opt_s3_host_name= DEFAULT_AWS_HOST_NAME;
4040
static const char *opt_database;
4141
static const char *opt_s3_bucket="MariaDB";
4242
static my_bool opt_compression, opt_verbose, opt_force, opt_s3_debug;
43+
static my_bool opt_s3_use_http;
4344
static ulong opt_operation= OP_IMPOSSIBLE, opt_protocol_version= 1;
4445
static ulong opt_block_size;
46+
static ulong opt_s3_port;
4547
static char **default_argv=0;
4648
static ms3_st *global_s3_client= 0;
4749

@@ -65,6 +67,12 @@ static struct my_option my_long_options[] =
6567
{"s3_host_name", 'h', "Host name to S3 provider",
6668
(char**) &opt_s3_host_name, (char**) &opt_s3_host_name, 0,
6769
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
70+
{"s3_port", 'p', "Port number to connect to (0 means use default)",
71+
(char**) &opt_s3_port, (char**) &opt_s3_port, 0, GET_ULONG, REQUIRED_ARG,
72+
0, 0, 65536, 0, 1, 0 },
73+
{"s3_use_http", 'P', "If true, force use of HTTP protocol",
74+
(char**) &opt_s3_use_http, (char**) &opt_s3_use_http,
75+
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
6876
{"compress", 'c', "Use compression", &opt_compression, &opt_compression,
6977
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
7078
{"op", 'o', "Operation to execute. One of 'from_s3', 'to_s3' or "
@@ -196,6 +204,7 @@ int main(int argc, char** argv)
196204
{
197205
MY_INIT(argv[0]);
198206
get_options(&argc,(char***) &argv);
207+
size_t block_size= opt_block_size;
199208

200209
s3_init_library();
201210
if (!(global_s3_client= ms3_init(opt_s3_access_key,
@@ -207,15 +216,22 @@ int main(int argc, char** argv)
207216
my_exit(1);
208217
}
209218

219+
ms3_set_option(global_s3_client, MS3_OPT_BUFFER_CHUNK_SIZE, &block_size);
220+
221+
if (opt_protocol_version)
210222
{
211-
size_t block_size= opt_block_size;
212223
uint8_t protocol_version= (uint8_t) opt_protocol_version;
213-
ms3_set_option(global_s3_client, MS3_OPT_BUFFER_CHUNK_SIZE, &block_size);
214-
215-
if (protocol_version)
216-
ms3_set_option(global_s3_client, MS3_OPT_FORCE_PROTOCOL_VERSION,
217-
&protocol_version);
224+
ms3_set_option(global_s3_client, MS3_OPT_FORCE_PROTOCOL_VERSION,
225+
&protocol_version);
218226
}
227+
if (opt_s3_port)
228+
{
229+
int port= (int) opt_s3_port;
230+
ms3_set_option(global_s3_client, MS3_OPT_PORT_NUMBER, &port);
231+
}
232+
if (opt_s3_use_http)
233+
ms3_set_option(global_s3_client, MS3_OPT_USE_HTTP, NULL);
234+
219235

220236
for (; *argv ; argv++)
221237
{

storage/maria/s3_func.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,8 +583,8 @@ int aria_copy_from_s3(ms3_st *s3_client, const char *aws_bucket,
583583

584584
if (s3_get_object(s3_client, aws_bucket, aws_path, &block, 0, 0))
585585
{
586-
my_printf_error(EE_FILENOTFOUND, "Table %s doesn't exist in s3", MYF(0),
587-
filename);
586+
my_printf_error(EE_FILENOTFOUND, "File %s/%s doesn't exist in s3", MYF(0),
587+
database,filename);
588588
goto err;
589589
}
590590
if (block.length < MARIA_STATE_INFO_SIZE)

0 commit comments

Comments
 (0)