Skip to content

Commit 3dcd00f

Browse files
committed
Merge branch 'api-cleanup' into wl10718-extended-auth
# Conflicts: # cdk/include/mysql/cdk/data_source.h # devapi/session.cc # include/mysql_devapi.h
2 parents 7462a6f + d6bbd9e commit 3dcd00f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+7413
-5308
lines changed

CMakeLists.txt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,14 @@ else()
204204
add_definitions(-DCONCPP_BUILD_SHARED)
205205
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
206206

207+
# Hide all symbols that are not explicitly exported.
207208
# Note: setting target property CXX_VISIBILITY did not work for
208209
# object libraries that we use to build the connector.
209210

210-
if(CMAKE_COMPILER_IS_GNUCXX)
211-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
212-
add_compile_options(-fvisibility-ms-compat)
213-
elseif()
214-
add_compile_options(-fvisibility=hidden)
215-
endif()
211+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
212+
add_compile_options(-fvisibility-ms-compat)
213+
elseif(CMAKE_COMPILER_IS_GNUCXX)
214+
add_compile_options(-fvisibility=hidden)
216215
endif()
217216

218217
endif()
@@ -518,6 +517,8 @@ SET_INTERFACE_OPTIONS(try devapi)
518517
# TODO: Do it also for the shared library
519518
#
520519

520+
if(NOT WIN32)
521+
521522
find_program(LDD ldd)
522523
if(NOT LDD)
523524
find_program(LDD otool)
@@ -533,6 +534,8 @@ if(LDD)
533534
)
534535
endif()
535536

537+
endif()
538+
536539
#
537540
# Linking test
538541
#
@@ -591,11 +594,11 @@ if(NOT CMAKE_INSTALL_PREFIX)
591594
else()
592595
set(install_prefix "C:/Program Files (x86)")
593596
endif()
594-
set(CMAKE_INSTALL_PREFIX "${install_prefix}/MySQL/MySQL Connector C++ 2.0")
597+
set(CMAKE_INSTALL_PREFIX "${install_prefix}/MySQL/MySQL Connector C++ ${CONCPP_PACKAGE_BASE_VERSION}")
595598

596599
else()
597600

598-
set(CMAKE_INSTALL_PREFIX "/usr/local/mysql/connector-c++-2.0")
601+
set(CMAKE_INSTALL_PREFIX "/usr/local/mysql/connector-c++-${CONCPP_PACKAGE_BASE_VERSION}")
599602

600603
endif()
601604

README.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MySQL Connector/C++ 2.0
1+
MySQL Connector/C++ 8.0
22

33
This is a release of MySQL Connector/C++, Oracle's
44
dual-license C++ API for connecting client applications
@@ -46,6 +46,9 @@ DOCUMENTATION LOCATION
4646
You can find the documentation on the MySQL website at
4747
<http://dev.mysql.com/doc/dev/connector-cpp/>
4848

49+
For the new features/bugfix history, see release notes at
50+
<https://dev.mysql.com/doc/relnotes/connector-cpp/en/news-8-0-5.html>.
51+
Note that the initial releases used major version 2.0.
4952

5053
CONTACT
5154
=======

cdk/cmake/headers.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,29 @@ SET(headers_dir "${headers_dir}/headers")
5959
#MESSAGE("headers.cmake: ${headers_dir}")
6060

6161

62+
#
63+
# Check if given list of headers includes all headers that can be found in
64+
# the current directory.
65+
#
66+
67+
function(check_headers)
68+
69+
file(GLOB all_headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
70+
71+
foreach(header IN LISTS ARGV)
72+
#message("- checking header: ${header}\n")
73+
list(REMOVE_ITEM all_headers ${header})
74+
endforeach()
75+
76+
list(LENGTH all_headers remains)
77+
78+
if(remains GREATER 0)
79+
message(WARNING "Extra headers found in ${CMAKE_CURRENT_SOURCE_DIR}: ${all_headers}")
80+
endif()
81+
82+
endfunction()
83+
84+
6285
#
6386
# Set-up header declarations with given folder as a base location for all
6487
# public headers.

cdk/core/session.cc

Lines changed: 72 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct Session_builder
4040
{
4141
using TLS = cdk::connection::TLS;
4242
using TCPIP = cdk::connection::TCPIP;
43+
using Socket_base = foundation::connection::Socket_base;
4344

4445
cdk::api::Connection *m_conn = NULL;
4546
mysqlx::Session *m_sess = NULL;
@@ -67,27 +68,26 @@ struct Session_builder
6768
3. If a bail-out error was detected, throws that error.
6869
*/
6970

71+
Socket_base* connect(Socket_base*);
72+
7073
bool operator() (const ds::TCPIP &ds, const ds::TCPIP::Options &options);
74+
#ifndef WIN32
75+
bool operator() (const ds::Unix_socket&ds, const ds::Unix_socket::Options &options);
76+
#endif
7177
bool operator() (const ds::TCPIP_old &ds, const ds::TCPIP_old::Options &options);
7278

7379
#ifdef WITH_SSL
74-
TLS* tls_connect(TCPIP &conn, const TLS::Options &opt);
80+
TLS* tls_connect(Socket_base &conn, const TLS::Options &opt);
7581
#endif
7682
};
7783

7884

79-
bool
80-
Session_builder::operator() (
81-
const ds::TCPIP &ds,
82-
const ds::TCPIP::Options &options
83-
)
85+
Session_builder::Socket_base*
86+
Session_builder::connect(Session_builder::Socket_base* connection)
8487
{
85-
using foundation::connection::TCPIP;
86-
using foundation::connection::TCPIP_base;
87-
8888
m_attempts++;
8989

90-
TCPIP* connection = new TCPIP(ds.host(), ds.port());
90+
assert(connection);
9191

9292
try
9393
{
@@ -115,8 +115,25 @@ Session_builder::operator() (
115115
m_error.reset(err.clone());
116116
}
117117

118-
return false; // continue to next host if available
118+
return NULL;
119119
}
120+
return connection;
121+
}
122+
123+
124+
bool
125+
Session_builder::operator() (
126+
const ds::TCPIP &ds,
127+
const ds::TCPIP::Options &options
128+
)
129+
{
130+
using foundation::connection::TCPIP;
131+
using foundation::connection::Socket_base;
132+
133+
Socket_base* connection = connect(new TCPIP(ds.host(), ds.port()));
134+
135+
if (!connection)
136+
return false; // continue to next host if available
120137

121138
#ifdef WITH_SSL
122139
TLS *tls_conn = tls_connect(*connection, options.get_tls());
@@ -137,6 +154,31 @@ Session_builder::operator() (
137154
return true;
138155
}
139156

157+
#ifndef WIN32
158+
bool
159+
Session_builder::operator() (
160+
const ds::Unix_socket &ds,
161+
const ds::Unix_socket::Options &options
162+
)
163+
{
164+
using foundation::connection::Unix_socket;
165+
using foundation::connection::Socket_base;
166+
167+
Socket_base* connection = connect(new Unix_socket(ds.path()));
168+
169+
if (!connection)
170+
return false; // continue to next host if available
171+
172+
m_conn = connection;
173+
m_sess = new mysqlx::Session(*connection, options);
174+
175+
m_database = options.database();
176+
177+
return true;
178+
}
179+
180+
#endif //#ifndef WIN32
181+
140182

141183
bool
142184
Session_builder::operator() (
@@ -152,7 +194,7 @@ Session_builder::operator() (
152194
#ifdef WITH_SSL
153195

154196
Session_builder::TLS*
155-
Session_builder::tls_connect(TCPIP &connection, const TLS::Options &options)
197+
Session_builder::tls_connect(Socket_base &connection, const TLS::Options &options)
156198
{
157199
if (!options.get_ca().empty() &&
158200
options.ssl_mode() < TLS::Options::SSL_MODE::VERIFY_CA)
@@ -278,6 +320,24 @@ Session::Session(ds::Multi_source &ds)
278320
}
279321

280322

323+
#ifndef WIN32
324+
Session::Session(ds::Unix_socket &ds, const ds::Unix_socket::Options &options)
325+
: m_session(NULL)
326+
, m_connection(NULL)
327+
, m_trans(false)
328+
{
329+
Session_builder sb(true); // throw errors if detected
330+
331+
sb(ds, options);
332+
333+
assert(sb.m_sess);
334+
335+
m_session = sb.m_sess;
336+
m_connection = sb.m_conn;
337+
}
338+
#endif //#ifndef WIN32
339+
340+
281341
Session::~Session()
282342
{
283343
if (m_trans)

cdk/core/tests/session-t.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,6 +1243,23 @@ TEST_F(Session_core, failover)
12431243
ms.add(ds_correct, options_db2, highest_priority - 1);
12441244
ms.add(ds_correct, options_db3, highest_priority - 1);
12451245

1246+
#ifndef _WIN32
1247+
ds::Unix_socket ds_correct_unix("/tmp/varxpl/tmp/mysqlx.1.sock");
1248+
ds::Unix_socket::Options options_unix_db1("root");
1249+
options_db1.set_database("failover_test_unix_1");
1250+
1251+
ds::Unix_socket::Options options_unix_db2("root");
1252+
options_db2.set_database("failover_test_unix_2");
1253+
1254+
ds::Unix_socket::Options options_unix_db3("root");
1255+
options_db3.set_database("failover_test_unix_3");
1256+
1257+
ms.add(ds_correct_unix, options_unix_db1, highest_priority - 1);
1258+
ms.add(ds_correct_unix, options_unix_db2, highest_priority - 1);
1259+
ms.add(ds_correct_unix, options_unix_db3, highest_priority - 1);
1260+
1261+
#endif
1262+
12461263
struct : cdk::Row_processor
12471264
{
12481265
// Row_processor callbacks

0 commit comments

Comments
 (0)