Commit 494a75c8 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-28888 : Embedded MariaDB does not build on Windows

Add limited support for building embedded library (DLL only).
parent 0c62b6d5
...@@ -154,7 +154,11 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) ...@@ -154,7 +154,11 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
# (can be a static or shared lib) # (can be a static or shared lib)
IF(LIB_TYPE STREQUAL "STATIC_LIBRARY") IF(LIB_TYPE STREQUAL "STATIC_LIBRARY")
SET(STATIC_TGTS ${STATIC_TGTS} ${LIB}) SET(STATIC_TGTS ${STATIC_TGTS} ${LIB})
SET(STATIC_LIBS ${STATIC_LIBS} $<TARGET_FILE:${LIB}>) IF(MSVC)
TARGET_LINK_LIBRARIES(${TARGET} PRIVATE ${LIB})
ELSE()
SET(STATIC_LIBS ${STATIC_LIBS} $<TARGET_FILE:${LIB}>)
ENDIF()
ADD_DEPENDENCIES(${TARGET} ${LIB}) ADD_DEPENDENCIES(${TARGET} ${LIB})
# Extract dependent OS libraries # Extract dependent OS libraries
GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS) GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS)
......
...@@ -148,6 +148,7 @@ ADD_DEPENDENCIES(sql_embedded GenError GenServerSource) ...@@ -148,6 +148,7 @@ ADD_DEPENDENCIES(sql_embedded GenError GenServerSource)
IF(TARGET pcre2) IF(TARGET pcre2)
ADD_DEPENDENCIES(sql_embedded pcre2) ADD_DEPENDENCIES(sql_embedded pcre2)
ENDIF() ENDIF()
TARGET_LINK_LIBRARIES(sql_embedded LINK_PRIVATE tpool ${CRC32_LIBRARY})
# On Windows, static embedded server library is called mysqlserver.lib # On Windows, static embedded server library is called mysqlserver.lib
# On Unix, it is libmysqld.a # On Unix, it is libmysqld.a
......
...@@ -485,7 +485,7 @@ MYSQL_METHODS embedded_methods= ...@@ -485,7 +485,7 @@ MYSQL_METHODS embedded_methods=
char **copy_arguments(int argc, char **argv) char **copy_arguments(int argc, char **argv)
{ {
uint length= 0; size_t length= 0;
char **from, **res, **end= argv+argc; char **from, **res, **end= argv+argc;
for (from=argv ; from != end ; from++) for (from=argv ; from != end ; from++)
...@@ -1100,11 +1100,11 @@ bool Protocol_text::store_field_metadata(const THD * thd, ...@@ -1100,11 +1100,11 @@ bool Protocol_text::store_field_metadata(const THD * thd,
client_field->flags= (uint16) server_field.flags; client_field->flags= (uint16) server_field.flags;
client_field->decimals= server_field.decimals; client_field->decimals= server_field.decimals;
client_field->db_length= strlen(client_field->db); client_field->db_length= (uint)strlen(client_field->db);
client_field->table_length= strlen(client_field->table); client_field->table_length= (uint)strlen(client_field->table);
client_field->name_length= strlen(client_field->name); client_field->name_length= (uint)strlen(client_field->name);
client_field->org_name_length= strlen(client_field->org_name); client_field->org_name_length= (uint)strlen(client_field->org_name);
client_field->org_table_length= strlen(client_field->org_table); client_field->org_table_length= (uint)strlen(client_field->org_table);
client_field->catalog= dup_str_aux(field_alloc, "def", 3, cs, thd_cs); client_field->catalog= dup_str_aux(field_alloc, "def", 3, cs, thd_cs);
client_field->catalog_length= 3; client_field->catalog_length= 3;
...@@ -1378,12 +1378,12 @@ bool Protocol::net_store_data(const uchar *from, size_t length) ...@@ -1378,12 +1378,12 @@ bool Protocol::net_store_data(const uchar *from, size_t length)
if (!(field_buf= (char*) alloc_root(alloc, length + sizeof(uint) + 1))) if (!(field_buf= (char*) alloc_root(alloc, length + sizeof(uint) + 1)))
return TRUE; return TRUE;
*(uint *)field_buf= length; *(uint *)field_buf= (uint)length;
*next_field= field_buf + sizeof(uint); *next_field= field_buf + sizeof(uint);
memcpy((uchar*) *next_field, from, length); memcpy((uchar*) *next_field, from, length);
(*next_field)[length]= 0; (*next_field)[length]= 0;
if (next_mysql_field->max_length < length) if (next_mysql_field->max_length < length)
next_mysql_field->max_length=length; next_mysql_field->max_length=(ulong)length;
++next_field; ++next_field;
++next_mysql_field; ++next_mysql_field;
return FALSE; return FALSE;
...@@ -1393,7 +1393,7 @@ bool Protocol::net_store_data(const uchar *from, size_t length) ...@@ -1393,7 +1393,7 @@ bool Protocol::net_store_data(const uchar *from, size_t length)
bool Protocol::net_store_data_cs(const uchar *from, size_t length, bool Protocol::net_store_data_cs(const uchar *from, size_t length,
CHARSET_INFO *from_cs, CHARSET_INFO *to_cs) CHARSET_INFO *from_cs, CHARSET_INFO *to_cs)
{ {
uint conv_length= to_cs->mbmaxlen * length / from_cs->mbminlen; size_t conv_length= length * to_cs->mbmaxlen / from_cs->mbminlen;
uint dummy_error; uint dummy_error;
char *field_buf; char *field_buf;
if (!thd->mysql) // bootstrap file handling if (!thd->mysql) // bootstrap file handling
...@@ -1404,10 +1404,10 @@ bool Protocol::net_store_data_cs(const uchar *from, size_t length, ...@@ -1404,10 +1404,10 @@ bool Protocol::net_store_data_cs(const uchar *from, size_t length,
*next_field= field_buf + sizeof(uint); *next_field= field_buf + sizeof(uint);
length= copy_and_convert(*next_field, conv_length, to_cs, length= copy_and_convert(*next_field, conv_length, to_cs,
(const char*) from, length, from_cs, &dummy_error); (const char*) from, length, from_cs, &dummy_error);
*(uint *) field_buf= length; *(uint *) field_buf= (uint)length;
(*next_field)[length]= 0; (*next_field)[length]= 0;
if (next_mysql_field->max_length < length) if (next_mysql_field->max_length < length)
next_mysql_field->max_length= length; next_mysql_field->max_length= (ulong)length;
++next_field; ++next_field;
++next_mysql_field; ++next_mysql_field;
return false; return false;
......
...@@ -1827,6 +1827,13 @@ extern "C" sig_handler print_signal_warning(int sig) ...@@ -1827,6 +1827,13 @@ extern "C" sig_handler print_signal_warning(int sig)
#endif #endif
} }
#ifdef _WIN32
typedef void (*report_svc_status_t)(DWORD current_state, DWORD win32_exit_code,
DWORD wait_hint);
static void dummy_svc_status(DWORD, DWORD, DWORD) {}
static report_svc_status_t my_report_svc_status= dummy_svc_status;
#endif
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
extern "C" void unireg_abort(int exit_code) extern "C" void unireg_abort(int exit_code)
{ {
...@@ -1872,13 +1879,6 @@ extern "C" void unireg_abort(int exit_code) ...@@ -1872,13 +1879,6 @@ extern "C" void unireg_abort(int exit_code)
mysqld_exit(exit_code); mysqld_exit(exit_code);
} }
#ifdef _WIN32
typedef void (*report_svc_status_t)(DWORD current_state, DWORD win32_exit_code,
DWORD wait_hint);
static void dummy_svc_status(DWORD, DWORD, DWORD) {}
static report_svc_status_t my_report_svc_status= dummy_svc_status;
#endif
static void mysqld_exit(int exit_code) static void mysqld_exit(int exit_code)
{ {
DBUG_ENTER("mysqld_exit"); DBUG_ENTER("mysqld_exit");
...@@ -4564,6 +4564,7 @@ void ssl_acceptor_stats_update(int sslaccept_ret) ...@@ -4564,6 +4564,7 @@ void ssl_acceptor_stats_update(int sslaccept_ret)
static void init_ssl() static void init_ssl()
{ {
#if !defined(EMBEDDED_LIBRARY)
/* /*
Not need to check require_secure_transport on the Linux, Not need to check require_secure_transport on the Linux,
because it always has Unix domain sockets that are secure: because it always has Unix domain sockets that are secure:
...@@ -4579,7 +4580,7 @@ static void init_ssl() ...@@ -4579,7 +4580,7 @@ static void init_ssl()
unireg_abort(1); unireg_abort(1);
} }
#endif #endif
#if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) #if defined(HAVE_OPENSSL)
if (opt_use_ssl) if (opt_use_ssl)
{ {
enum enum_ssl_init_error error= SSL_INITERR_NOERROR; enum enum_ssl_init_error error= SSL_INITERR_NOERROR;
...@@ -4620,7 +4621,8 @@ static void init_ssl() ...@@ -4620,7 +4621,8 @@ static void init_ssl()
} }
if (des_key_file) if (des_key_file)
load_des_key_file(des_key_file); load_des_key_file(des_key_file);
#endif /* HAVE_OPENSSL && ! EMBEDDED_LIBRARY */ #endif /* HAVE_OPENSSL */
#endif /* !EMBEDDED_LIBRARY */
} }
/* Reinitialize SSL (FLUSH SSL) */ /* Reinitialize SSL (FLUSH SSL) */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment