Skip to content

Commit 35034d8

Browse files
vuvovasanja-byelkin
authored andcommitted
S3 is pluggable now
1 parent 4acafaa commit 35034d8

File tree

17 files changed

+127
-114
lines changed

17 files changed

+127
-114
lines changed

debian/control

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,15 @@ Description: Connect storage engine for MariaDB
623623
other interesting features.
624624
This package contains the Connect plugin for MariaDB.
625625

626+
Package: mariadb-plugin-s3
627+
Architecture: any
628+
Depends: libcurl4,
629+
mariadb-server-10.5 (= ${binary:Version}),
630+
${misc:Depends},
631+
${shlibs:Depends}
632+
Description: S3 storage engine for MariaDB
633+
Read only table stored in S3.
634+
626635
Package: mariadb-plugin-rocksdb
627636
Architecture: amd64 arm64 mips64el ppc64el
628637
Depends: mariadb-server-10.5 (= ${binary:Version}),

debian/mariadb-plugin-s3.install

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
etc/mysql/mariadb.conf.d/s3.cnf
2+
usr/bin/aria_s3_copy
3+
usr/lib/mysql/plugin/ha_s3.so

include/aria_backup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2018 MariaDB corporation
1+
/* Copyright (C) 2018,2020 MariaDB Corporation Ab
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by

mysql-test/suite/s3/my.cnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
!include include/default_client.cnf
33

44
[mysqld.1]
5+
plugin-load-add=ha_s3
56
s3=ON
67
#s3-host-name=s3.amazonaws.com
78
#s3-protocol-version=Amazon

mysql-test/suite/s3/suite.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package My::Suite::S3;
22

33
@ISA = qw(My::Suite);
44

5-
return "Need S3 engine" unless $::mysqld_variables{'s3'} eq "ON";
5+
return "Need S3 engine" unless $::mysqld_variables{'s3'} eq "ON" or $ENV{HA_S3_SO};
66

77
bless { };
88

storage/maria/CMakeLists.txt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (C) 2007 MySQL AB
2+
# Copyright (C) 2009,2020 MariaDB Corporation Ab
23
#
34
# This program is free software; you can redistribute it and/or modify
45
# it under the terms of the GNU General Public License as published by
@@ -105,7 +106,7 @@ OPTION(USE_ARIA_FOR_TMP_TABLES "Use Aria for temporary tables" ON)
105106
#
106107
INCLUDE (CheckIncludeFiles)
107108

108-
SET(S3_SOURCES ha_s3.cc s3_func.c
109+
SET(S3_SOURCES s3_func.c
109110
libmarias3/src/debug.c libmarias3/src/error.c libmarias3/src/marias3.c
110111
libmarias3/src/request.c libmarias3/src/response.c libmarias3/src/sha256.c
111112
libmarias3/src/sha256-internal.c libmarias3/src/xml.c)
@@ -115,18 +116,13 @@ IF(NOT PLUGIN_S3 STREQUAL NO)
115116
ENDIF()
116117

117118
IF (CURL_FOUND)
118-
MYSQL_ADD_PLUGIN(s3 ${S3_SOURCES} STORAGE_ENGINE STATIC_ONLY
119-
LINK_LIBRARIES aria myisam mysys mysys_ssl curl
120-
NOT_EMBEDDED)
119+
MYSQL_ADD_PLUGIN(s3 ha_s3.cc ${S3_SOURCES} COMPONENT s3-engine
120+
LINK_LIBRARIES curl STORAGE_ENGINE NOT_EMBEDDED CONFIG s3.cnf)
121121
ENDIF()
122122

123123
IF(TARGET s3)
124-
MYSQL_ADD_EXECUTABLE(aria_s3_copy aria_s3_copy.cc COMPONENT Server)
125-
TARGET_LINK_LIBRARIES(aria_s3_copy s3)
126-
124+
MYSQL_ADD_EXECUTABLE(aria_s3_copy aria_s3_copy.cc ${S3_SOURCES} COMPONENT s3-engine)
125+
TARGET_LINK_LIBRARIES(aria_s3_copy aria myisam mysys mysys_ssl curl)
127126
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/libmarias3)
128-
129127
ADD_DEFINITIONS(-DWITH_S3_STORAGE_ENGINE)
130-
131-
TARGET_LINK_LIBRARIES(aria s3)
132128
ENDIF()

storage/maria/ha_maria.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* Copyright (C) 2004-2008 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
22
Copyright (C) 2008-2009 Sun Microsystems, Inc.
3-
Copyright (c) 2009, 2017, MariaDB Corporation.
3+
Copyright (c) 2009, 2020, MariaDB Corporation Ab
44
55
This program is free software; you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -72,7 +72,7 @@ const char *zerofill_error_msg=
7272
corrupted.
7373
*/
7474
ulonglong maria_recover_options= HA_RECOVER_NONE;
75-
handlerton *maria_hton;
75+
handlerton __attribute__((visibility("default"))) *maria_hton;
7676

7777
/* bits in maria_recover_options */
7878
const char *maria_recover_names[]=
@@ -2688,6 +2688,16 @@ int ha_maria::extra_opt(enum ha_extra_function operation, ulong cache_size)
26882688
}
26892689

26902690

2691+
bool ha_maria::auto_repair(int error) const
2692+
{
2693+
/* Always auto-repair moved tables (error == HA_ERR_OLD_FILE) */
2694+
return ((MY_TEST(maria_recover_options & HA_RECOVER_ANY) &&
2695+
error == HA_ERR_CRASHED_ON_USAGE) ||
2696+
error == HA_ERR_OLD_FILE);
2697+
2698+
}
2699+
2700+
26912701
int ha_maria::delete_all_rows()
26922702
{
26932703
THD *thd= table->in_use;
@@ -3348,6 +3358,14 @@ ha_rows ha_maria::records_in_range(uint inx, const key_range *min_key,
33483358
}
33493359

33503360

3361+
FT_INFO *ha_maria::ft_init_ext(uint flags, uint inx, String * key)
3362+
{
3363+
return maria_ft_init_search(flags, file, inx,
3364+
(uchar *) key->ptr(), key->length(),
3365+
key->charset(), table->record[0]);
3366+
}
3367+
3368+
33513369
int ha_maria::ft_read(uchar * buf)
33523370
{
33533371
int error;

storage/maria/ha_maria.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef HA_MARIA_INCLUDED
22
#define HA_MARIA_INCLUDED
3-
/* Copyright (C) 2006,2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
3+
/* Copyright (C) 2006, 2004 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
4+
Copyright (c) 2009, 2020, MariaDB Corporation Ab
45
56
This program is free software; you can redistribute it and/or modify
67
it under the terms of the GNU General Public License as published by
@@ -38,7 +39,7 @@ C_MODE_END
3839
extern TYPELIB maria_recover_typelib;
3940
extern ulonglong maria_recover_options;
4041

41-
class ha_maria :public handler
42+
class __attribute__((visibility("default"))) ha_maria :public handler
4243
{
4344
public:
4445
MARIA_HA *file;
@@ -97,12 +98,7 @@ class ha_maria :public handler
9798
ft_handler->please->reinit_search(ft_handler);
9899
return 0;
99100
}
100-
FT_INFO *ft_init_ext(uint flags, uint inx, String * key)
101-
{
102-
return maria_ft_init_search(flags, file, inx,
103-
(uchar *) key->ptr(), key->length(),
104-
key->charset(), table->record[0]);
105-
}
101+
FT_INFO *ft_init_ext(uint flags, uint inx, String * key);
106102
int ft_read(uchar * buf);
107103
int index_init(uint idx, bool sorted);
108104
int index_end();
@@ -146,14 +142,7 @@ class ha_maria :public handler
146142
bool check_and_repair(THD * thd);
147143
bool is_crashed() const;
148144
bool is_changed() const;
149-
bool auto_repair(int error) const
150-
{
151-
/* Always auto-repair moved tables (error == HA_ERR_OLD_FILE) */
152-
return ((MY_TEST(maria_recover_options & HA_RECOVER_ANY) &&
153-
error == HA_ERR_CRASHED_ON_USAGE) ||
154-
error == HA_ERR_OLD_FILE);
155-
156-
}
145+
bool auto_repair(int error) const;
157146
int optimize(THD * thd, HA_CHECK_OPT * check_opt);
158147
int assign_to_keycache(THD * thd, HA_CHECK_OPT * check_opt);
159148
int preload_keys(THD * thd, HA_CHECK_OPT * check_opt);

storage/maria/ha_s3.cc

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2019 MariaDB Corppration AB
1+
/* Copyright (C) 2019, 2020 MariaDB Corporation Ab
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -1008,9 +1008,24 @@ static int ha_s3_init(void *p)
10081008
s3_init_library();
10091009
if (s3_debug)
10101010
ms3_debug();
1011+
1012+
struct s3_func s3f_real =
1013+
{
1014+
ms3_set_option, s3_free, ms3_deinit, s3_unique_file_number,
1015+
read_index_header, s3_check_frm_version, s3_info_copy,
1016+
set_database_and_table_from_path, s3_open_connection
1017+
};
1018+
s3f= s3f_real;
1019+
10111020
return res ? HA_ERR_INITIALIZATION : 0;
10121021
}
10131022

1023+
static int ha_s3_deinit(void*)
1024+
{
1025+
bzero(&s3f, sizeof(s3f));
1026+
return 0;
1027+
}
1028+
10141029
static SHOW_VAR status_variables[]= {
10151030
{"pagecache_blocks_not_flushed",
10161031
(char*) &s3_pagecache.global_blocks_changed, SHOW_LONG},
@@ -1057,7 +1072,7 @@ maria_declare_plugin(s3)
10571072
"ALTER TABLE table_name ENGINE=s3",
10581073
PLUGIN_LICENSE_GPL,
10591074
ha_s3_init, /* Plugin Init */
1060-
NULL, /* Plugin Deinit */
1075+
ha_s3_deinit, /* Plugin Deinit */
10611076
0x0100, /* 1.0 */
10621077
status_variables, /* status variables */
10631078
system_variables, /* system variables */

storage/maria/ma_backup.c

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (C) 2018 MariaDB corporation
1+
/* Copyright (C) 2018, 2020 MariaDB Corporation Ab
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License as published by
@@ -20,8 +20,6 @@
2020
#include "ma_checkpoint.h"
2121
#include <aria_backup.h>
2222

23-
static uchar *_ma_base_info_read(uchar *ptr, MARIA_BASE_INFO *base);
24-
2523
/**
2624
@brief Get capabilites for an Aria table
2725
@@ -32,6 +30,7 @@ static uchar *_ma_base_info_read(uchar *ptr, MARIA_BASE_INFO *base);
3230
@return X errno
3331
*/
3432

33+
int aria_get_capabilities(File kfile, ARIA_TABLE_CAPABILITIES *cap)__attribute__((visibility("default"))) ;
3534
int aria_get_capabilities(File kfile, ARIA_TABLE_CAPABILITIES *cap)
3635
{
3736
MARIA_SHARE share;
@@ -102,20 +101,13 @@ int aria_get_capabilities(File kfile, ARIA_TABLE_CAPABILITIES *cap)
102101
err:
103102
my_free(disc_cache);
104103
DBUG_RETURN(error);
105-
} /* maria_get_capabilities */
106-
104+
} /* aria_get_capabilities */
107105

108-
/*
109-
This is a copy of my_base_info_read from ma_open().
110-
The base information will never change (something may be added
111-
last, but not relevant for maria_get_capabilities), so it's safe to
112-
copy it here.
113-
114-
The copy is done to avoid linking in the fill Aria library just
115-
because maria_backup uses maria_get_capabilities()
116-
*/
106+
/****************************************************************************
107+
** store MARIA_BASE_INFO
108+
****************************************************************************/
117109

118-
static uchar *_ma_base_info_read(uchar *ptr, MARIA_BASE_INFO *base)
110+
uchar *_ma_base_info_read(uchar *ptr, MARIA_BASE_INFO *base)
119111
{
120112
bmove(base->uuid, ptr, MY_UUID_SIZE); ptr+= MY_UUID_SIZE;
121113
base->keystart= mi_sizekorr(ptr); ptr+= 8;

0 commit comments

Comments
 (0)