Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
7.9 kB · 207 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208diff --git a/include/my_char_traits.h b/include/my_char_traits.hnew file mode 100644index 00000000000..6336bc039c8--- /dev/null+++ b/include/my_char_traits.h@@ -0,0 +1,65 @@+/* Copyright (c) 2024, Oracle and/or its affiliates.++ This program is free software; you can redistribute it and/or modify+ it under the terms of the GNU General Public License, version 2.0,+ as published by the Free Software Foundation.++ This program is designed to work with certain software (including+ but not limited to OpenSSL) that is licensed under separate terms,+ as designated in a particular file or component or in included license+ documentation. The authors of MySQL hereby grant you an additional+ permission to link the program and your derivative works with the+ separately licensed software that they have either included with+ the program or referenced in the documentation.++ 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, version 2.0, 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 */++#ifndef MY_CHAR_TRAITS_INCLUDED+#define MY_CHAR_TRAITS_INCLUDED++#include <cstring>++template <class CharT>+struct my_char_traits;++/*+ This is a standards-compliant, drop-in replacement for+ std::char_traits<unsigned char>+ We need this because clang libc++ is removing support for it in clang 19.+ It is not a complete implementation. Rather we implement just enough to+ compile any usage of char_traits<uchar> we have in our codebase.+ */+template <>+struct my_char_traits<unsigned char> {+ using char_type = unsigned char;+ using int_type = unsigned int;++ static void assign(char_type &c1, const char_type &c2) { c1 = c2; }++ static char_type *assign(char_type *s, std::size_t n, char_type a) {+ return static_cast<char_type *>(memset(s, a, n));+ }++ static int compare(const char_type *s1, const char_type *s2, std::size_t n) {+ return memcmp(s1, s2, n);+ }++ static char_type *move(char_type *s1, const char_type *s2, std::size_t n) {+ if (n == 0) return s1;+ return static_cast<char_type *>(memmove(s1, s2, n));+ }++ static char_type *copy(char_type *s1, const char_type *s2, std::size_t n) {+ if (n == 0) return s1;+ return static_cast<char_type *>(memcpy(s1, s2, n));+ }+};++#endif // MY_CHAR_TRAITS_INCLUDEDdiff --git a/sql/mdl_context_backup.h b/sql/mdl_context_backup.hindex 89e7e23df34..cf9c307ec2d 100644--- a/sql/mdl_context_backup.h+++ b/sql/mdl_context_backup.h@@ -28,6 +28,7 @@ #include <map> #include <memory> +#include "my_char_traits.h" #include "sql/malloc_allocator.h" #include "sql/mdl.h" @@ -47,7 +48,8 @@ class MDL_context_backup_manager { /** Key for uniquely identifying MDL_context in the MDL_context_backup map. */- typedef std::basic_string<uchar> MDL_context_backup_key;+ using MDL_context_backup_key =+ std::basic_string<uchar, my_char_traits<uchar>>; class MDL_context_backup; diff --git a/sql/range_optimizer/index_range_scan_plan.cc b/sql/range_optimizer/index_range_scan_plan.ccindex 74fbb100397..8ed1f50da33 100644--- a/sql/range_optimizer/index_range_scan_plan.cc+++ b/sql/range_optimizer/index_range_scan_plan.cc@@ -54,6 +54,8 @@ #include "sql/thr_malloc.h" #include "sql_string.h" +#include "my_char_traits.h"+ using opt_range::null_element; using std::max; using std::min;@@ -1025,8 +1027,8 @@ static bool null_part_in_key(KEY_PART *key_part, const uchar *key, // TODO(sgunders): This becomes a bit simpler with C++20's string_view // constructors.-static inline std::basic_string_view<uchar> make_string_view(const uchar *start,- const uchar *end) {+static inline std::basic_string_view<uchar, my_char_traits<uchar>>+make_string_view(const uchar *start, const uchar *end) { return {start, static_cast<size_t>(end - start)}; } diff --git a/sql/stream_cipher.h b/sql/stream_cipher.hindex 606d40645c6..358fbb41959 100644--- a/sql/stream_cipher.h+++ b/sql/stream_cipher.h@@ -28,6 +28,8 @@ #include <memory> #include <string> +#include "my_char_traits.h"+ /** @file stream_cipher.h @@ -35,7 +37,8 @@ binary log files. */ -typedef std::basic_string<unsigned char> Key_string;+using Key_string =+ std::basic_string<unsigned char, my_char_traits<unsigned char>>; /** @class Stream_cipherdiff --git a/unittest/gunit/binlogevents/transaction_compression-t.cc b/unittest/gunit/binlogevents/transaction_compression-t.ccindex ba13f979aa3..01af0e3a360 100644--- a/unittest/gunit/binlogevents/transaction_compression-t.cc+++ b/unittest/gunit/binlogevents/transaction_compression-t.cc@@ -23,6 +23,7 @@ */ #include <array>+#include <string> #include <gtest/gtest.h> #include "libbinlogevents/include/binary_log.h"@@ -51,14 +52,13 @@ class TransactionPayloadCompressionTest : public ::testing::Test { using Managed_buffer_t = Decompressor_t::Managed_buffer_t; using Size_t = Decompressor_t::Size_t; using Char_t = Decompressor_t::Char_t;- using String_t = std::basic_string<Char_t>; using Decompress_status_t = binary_log::transaction::compression::Decompress_status; using Compress_status_t = binary_log::transaction::compression::Compress_status; - static String_t constant_data(Size_t size) {- return String_t(size, (Char_t)'a');+ static std::string constant_data(Size_t size) {+ return std::string(size, (Char_t)'a'); } protected:@@ -69,7 +69,7 @@ class TransactionPayloadCompressionTest : public ::testing::Test { void TearDown() override {} static void compression_idempotency_test(Compressor_t &c, Decompressor_t &d,- String_t data) {+ const std::string &data) { auto debug_string = concat( binary_log::transaction::compression::type_to_string(c.get_type_code()), " ", data.size());@@ -104,8 +104,8 @@ class TransactionPayloadCompressionTest : public ::testing::Test { // Check decompressed data ASSERT_EQ(managed_buffer.read_part().size(), data.size()) << debug_string;- ASSERT_EQ(data, String_t(managed_buffer.read_part().begin(),- managed_buffer.read_part().end()))+ ASSERT_EQ(data, std::string(managed_buffer.read_part().begin(),+ managed_buffer.read_part().end())) << debug_string; // Check that we reached EOF@@ -118,7 +118,7 @@ TEST_F(TransactionPayloadCompressionTest, CompressDecompressZstdTest) { for (auto size : buffer_sizes) { binary_log::transaction::compression::Zstd_dec d; binary_log::transaction::compression::Zstd_comp c;- String_t data{TransactionPayloadCompressionTest::constant_data(size)};+ std::string data{TransactionPayloadCompressionTest::constant_data(size)}; TransactionPayloadCompressionTest::compression_idempotency_test(c, d, data); c.set_compression_level(22); TransactionPayloadCompressionTest::compression_idempotency_test(c, d, data);@@ -129,7 +129,7 @@ TEST_F(TransactionPayloadCompressionTest, CompressDecompressNoneTest) { for (auto size : buffer_sizes) { binary_log::transaction::compression::None_dec d; binary_log::transaction::compression::None_comp c;- String_t data{TransactionPayloadCompressionTest::constant_data(size)};+ std::string data{TransactionPayloadCompressionTest::constant_data(size)}; TransactionPayloadCompressionTest::compression_idempotency_test(c, d, data); } }