Skip to content

Commit

Permalink
Merge branch 'mysql-5.7' into mysql-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Golebiowski committed Jul 5, 2016
2 parents a588584 + 7f21215 commit a957815
Show file tree
Hide file tree
Showing 36 changed files with 1,188 additions and 559 deletions.
2 changes: 1 addition & 1 deletion mysql-test/suite/auth_sec/r/install_keyring_file.result
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
call mtr.add_suppression("Cannot create keyring directory:");
call mtr.add_suppression("keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file or keyring file can be created in the specified location. The keyring_file will stay unusable until correct path to the keyring file gets provided");
call mtr.add_suppression("Could not create keyring directory The keyring_file will stay unusable until correct path to the keyring directory gets provided");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");
SET @@global.keyring_file_data= 'MYSQL_TMP_DIR/new_keyring_file';
ERROR HY000: Unknown system variable 'keyring_file_data'
INSTALL PLUGIN keyring_file SONAME 'keyring_file.so';
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/auth_sec/r/keyring_file_data.result
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
call mtr.add_suppression("Cannot create keyring directory:");
call mtr.add_suppression("keyring_file_data cannot be set to new value as the keyring file cannot be created/accessed in the provided path");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");
SELECT @@global.keyring_file_data;
@@global.keyring_file_data
MYSQL_TMP_DIR/mysecret_keyring
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/auth_sec/r/keyring_file_data_qa.result
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
call mtr.add_suppression("Cannot create keyring directory:");
call mtr.add_suppression("\\[Error\\] Function 'keyring_file' already exists");
call mtr.add_suppression("\\[Error\\] Couldn't load plugin named 'keyring_file' with soname 'keyring_file.so'.");
call mtr.add_suppression("keyring_file_data cannot be set to new value as the keyring file cannot be created/accessed in the provided path");
call mtr.add_suppression("\\[Error\\] Plugin keyring_file reported: 'keyring_file initialization failure.");
call mtr.add_suppression("Plugin keyring_file reported: 'Could not create keyring directory The keyring_file will stay unusable until correct path to the keyring directory gets provided");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");
INSTALL PLUGIN keyring_file SONAME 'keyring_file.so';
SELECT PLUGIN_NAME,PLUGIN_VERSION,PLUGIN_STATUS
FROM INFORMATION_SCHEMA.PLUGINS WHERE plugin_name='keyring_file';
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/auth_sec/r/wrong_keyring_file_data.result
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ call mtr.add_suppression("Plugin \'keyring_file\' init function returned error")
call mtr.add_suppression("Cannot create keyring directory: ../bad_dir/../..");
call mtr.add_suppression("Could not create keyring directory The keyring_file will stay unusable until correct path to the keyring directory gets provided");
call mtr.add_suppression("keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");
5 changes: 3 additions & 2 deletions mysql-test/suite/auth_sec/t/install_keyring_file.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
--disable_warnings
--source include/not_embedded.inc

call mtr.add_suppression("Cannot create keyring directory:");
call mtr.add_suppression("keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file or keyring file can be created in the specified location. The keyring_file will stay unusable until correct path to the keyring file gets provided");
call mtr.add_suppression("Could not create keyring directory The keyring_file will stay unusable until correct path to the keyring directory gets provided");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");


--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
--error ER_UNKNOWN_SYSTEM_VARIABLE
Expand All @@ -15,7 +16,7 @@ eval INSTALL PLUGIN keyring_file SONAME '$KEYRING_PLUGIN';

--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SET @@global.keyring_file_data= '$MYSQL_TMP_DIR/new_keyring_file';
# cleanup
#cleanup
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
eval SET @@global.keyring_file_data= '$MYSQL_TMP_DIR/mysecret_keyring';
UNINSTALL PLUGIN keyring_file;
3 changes: 2 additions & 1 deletion mysql-test/suite/auth_sec/t/keyring_file_data.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
--disable_ps_protocol
--disable_warnings
--source include/not_embedded.inc
call mtr.add_suppression("Cannot create keyring directory:");

call mtr.add_suppression("keyring_file_data cannot be set to new value as the keyring file cannot be created/accessed in the provided path");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");

--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
SELECT @@global.keyring_file_data;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/auth_sec/t/keyring_file_data_qa.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
--disable_ps_protocol
--disable_warnings
--source include/not_embedded.inc
call mtr.add_suppression("Cannot create keyring directory:");
call mtr.add_suppression("\\[Error\\] Function 'keyring_file' already exists");
call mtr.add_suppression("\\[Error\\] Couldn't load plugin named 'keyring_file' with soname 'keyring_file.so'.");
call mtr.add_suppression("keyring_file_data cannot be set to new value as the keyring file cannot be created/accessed in the provided path");
call mtr.add_suppression("\\[Error\\] Plugin keyring_file reported: 'keyring_file initialization failure.");
call mtr.add_suppression("Plugin keyring_file reported: 'Could not create keyring directory The keyring_file will stay unusable until correct path to the keyring directory gets provided");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");

# Installing keyring plugin.
--replace_regex /\.dll/.so/
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/auth_sec/t/wrong_keyring_file_data.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ call mtr.add_suppression("Plugin \'keyring_file\' init function returned error")
call mtr.add_suppression("Cannot create keyring directory: ../bad_dir/../..");
call mtr.add_suppression("Could not create keyring directory The keyring_file will stay unusable until correct path to the keyring directory gets provided");
call mtr.add_suppression("keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");
2 changes: 1 addition & 1 deletion mysql-test/suite/innodb/r/table_encrypt_5.result
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ call mtr.add_suppression("InnoDB: Failed to find tablespace for table");
call mtr.add_suppression("InnoDB: Cannot open table tde_db/t_encrypt.* from the internal data dictionary of InnoDB though the .frm file for the table exists");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Table tde_db/t_encrypt.* in the InnoDB data dictionary has tablespace id .*, but tablespace with that id or name does not exist");
call mtr.add_suppression("\\[Warning\\] InnoDB: Please refer to .* for how to resolve the issue");
call mtr.add_suppression("Cannot create keyring directory");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");
call mtr.add_suppression("\\[ERROR\\] Plugin keyring_file reported: 'Could not create keyring directory");
call mtr.add_suppression("\\[ERROR\\] Plugin keyring_file reported: 'keyring_file initialization failure.");
# Starting server with keyring plugin
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/innodb/t/table_encrypt_5.test
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ call mtr.add_suppression("InnoDB: Failed to find tablespace for table");
call mtr.add_suppression("InnoDB: Cannot open table tde_db/t_encrypt.* from the internal data dictionary of InnoDB though the .frm file for the table exists");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Table tde_db/t_encrypt.* in the InnoDB data dictionary has tablespace id .*, but tablespace with that id or name does not exist");
call mtr.add_suppression("\\[Warning\\] InnoDB: Please refer to .* for how to resolve the issue");
call mtr.add_suppression("Cannot create keyring directory");
call mtr.add_suppression("Error while loading keyring content. The keyring might be malformed");
call mtr.add_suppression("\\[ERROR\\] Plugin keyring_file reported: 'Could not create keyring directory");
call mtr.add_suppression("\\[ERROR\\] Plugin keyring_file reported: 'keyring_file initialization failure.");

Expand Down
9 changes: 6 additions & 3 deletions plugin/keyring/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

INCLUDE_DIRECTORIES(${BOOST_PATCHES_DIR} ${BOOST_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/common)

MYSQL_ADD_PLUGIN(keyring_file
keyring_key.cc
common/keyring_key.cc
common/keys_container.cc
common/keyring_impl.cc
keyring.cc
keys_container.cc
hash_to_buffer_serializer.cc
buffered_file_io.cc
keyring_impl.cc
buffer.cc
MODULE_ONLY
MODULE_OUTPUT_NAME "keyring_file")

Expand Down
68 changes: 68 additions & 0 deletions plugin/keyring/buffer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include "buffer.h"
#include "keyring_key.h"

namespace keyring
{
inline void Buffer::free()
{
if (data != NULL)
{
delete[] data;
data= NULL;
}
mark_as_empty();
DBUG_ASSERT(size == 0 && position == 0);
}

my_bool Buffer::get_next_key(IKey **key)
{
*key= NULL;

boost::movelib::unique_ptr<Key> key_ptr(new Key());
size_t number_of_bytes_read_from_buffer = 0;
if (data == NULL)
{
DBUG_ASSERT(size == 0);
return TRUE;
}
if (key_ptr->load_from_buffer(data + position,
&number_of_bytes_read_from_buffer,
size - position))
return TRUE;

position += number_of_bytes_read_from_buffer;
*key= key_ptr.release();
return FALSE;
}

my_bool Buffer::has_next_key()
{
return position < size;
}

void Buffer::reserve(size_t memory_size)
{
DBUG_ASSERT(memory_size % sizeof(size_t) == 0); //make sure size is sizeof(size_t) aligned
free();
data= reinterpret_cast<uchar*>(new size_t[memory_size / sizeof(size_t)]);//force size_t alignment
size= memory_size;
if(data)
memset(data, 0, size);
position= 0;
}
}
37 changes: 18 additions & 19 deletions plugin/keyring/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,33 @@
#define MYSQL_BUFFER_H

#include "keyring_memory.h"
#include "i_serialized_object.h"

struct Buffer
namespace keyring
{

class Buffer : public ISerialized_object
{
public:
Buffer() : data(NULL)
{
mark_as_empty();
}
Buffer(size_t memory_size) : data(NULL)
{
reserve(memory_size);
}
~Buffer()
{
if(data != NULL)
delete[] data;
}
inline void free()
{
if (data != NULL)
{
delete[] data;
data= NULL;
}
mark_as_empty();
}
void reserve(size_t memory_size)
{
DBUG_ASSERT(memory_size % sizeof(size_t) == 0); //make sure size is sizeof(size_t) aligned
data= reinterpret_cast<uchar*>(new size_t[memory_size / sizeof(size_t)]);//force size_t alignment
size= memory_size;
if(data)
memset(data, 0, size);
position= 0;
}

inline void free();
my_bool get_next_key(IKey **key);
my_bool has_next_key();
void reserve(size_t memory_size);

uchar *data;
size_t size;
size_t position;
Expand All @@ -60,4 +57,6 @@ struct Buffer
}
};

} //namespace keyring

#endif //MYSQL_BUFFER_H
Loading

0 comments on commit a957815

Please sign in to comment.