1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

fixes for windows

This commit is contained in:
Sergei Golubchik
2011-10-21 23:07:13 +02:00
parent b3223453f7
commit aeaa112edb
31 changed files with 57 additions and 145 deletions

View File

@ -24,7 +24,7 @@
#include "timer.hpp"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#else
#include <sys/time.h>

View File

@ -19,8 +19,6 @@
#ifndef _my_base_h
#define _my_base_h
#ifndef stdin /* Included first in handler */
#define CHSIZE_USED
#include <my_global.h>
#include <my_dir.h> /* This includes types */
#include <my_sys.h>
@ -31,7 +29,6 @@
#define EOVERFLOW 84
#endif
#endif /* stdin */
#include <my_list.h>
/* The following is bits in the flag parameter to ha_open() */

View File

@ -91,21 +91,6 @@ struct timespec {
long tv_nsec;
};
/**
Compare two timespec structs.
@retval 1 If TS1 ends after TS2.
@retval 0 If TS1 is equal to TS2.
@retval -1 If TS1 ends before TS2.
*/
#define cmp_timespec(TS1, TS2) \
((TS1.tv.i64 > TS2.tv.i64) ? 1 : \
((TS1.tv.i64 < TS2.tv.i64) ? -1 : 0))
int win_pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_create(pthread_t *, const pthread_attr_t *, pthread_handler, void *);
int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);

View File

@ -122,9 +122,9 @@ int PSIZE= sizeof(struct st_mysql_plugin); \
struct st_mysql_plugin DECLS[]= {
#define MARIA_DECLARE_PLUGIN__(NAME, VERSION, PSIZE, DECLS) \
int VERSION= MARIA_PLUGIN_INTERFACE_VERSION; \
int PSIZE= sizeof(struct st_maria_plugin); \
struct st_maria_plugin DECLS[]= {
MYSQL_PLUGIN_EXPORT int VERSION= MARIA_PLUGIN_INTERFACE_VERSION; \
MYSQL_PLUGIN_EXPORT int PSIZE= sizeof(struct st_maria_plugin); \
MYSQL_PLUGIN_EXPORT struct st_maria_plugin DECLS[]= {
#else
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \

View File

@ -15,6 +15,10 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#ifdef _WIN32
#include <windows.h>
#endif
/**
@file

View File

@ -56,6 +56,9 @@
#define LOCAL_HOST "localhost"
#define LOCAL_HOST_NAMEDPIPE "."
#ifdef _WIN32
#include <ws2tcpip.h>
#endif
#if defined(__WIN__) && !defined( _CUSTOMCONFIG_)
#define MYSQL_NAMEDPIPE "MySQL"

View File

@ -24,32 +24,16 @@
asks the user the question, as provided by the server and reports
the answer back to the server. No encryption is involved,
the answers are sent in clear text.
Two examples are provided: two_questions server plugin, that asks
the password and an "Are you sure?" question with a reply "yes, of course".
It demonstrates the usage of "password" (input is hidden) and "ordinary"
(input can be echoed) questions, and how to mark the last question,
to avoid an extra roundtrip.
And three_attempts plugin that gives the user three attempts to enter
a correct password. It shows the situation when a number of questions
is not known in advance.
*/
#if defined (WIN32) && !defined (RTLD_DEFAULT)
#include <my_global.h>
#include <mysql/client_plugin.h>
#include <mysql.h>
#include <string.h>
#if defined (_WIN32)
# define RTLD_DEFAULT GetModuleHandle(NULL)
#endif
#if !defined (_GNU_SOURCE)
# define _GNU_SOURCE /* for RTLD_DEFAULT */
#endif
#include <mysql/client_plugin.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <mysql.h>
#include <dlfcn.h>
/*
This plugin performs a dialog with the user, asking questions and
reading answers. Depending on the client it may be desirable to do it

View File

@ -47,11 +47,7 @@ static int getWaitTime(const struct timespec& start_ts);
static unsigned long long timespec_to_usec(const struct timespec *ts)
{
#ifndef __WIN__
return (unsigned long long) ts->tv_sec * TIME_MILLION + ts->tv_nsec / TIME_THOUSAND;
#else
return ts->tv.i64 / 10;
#endif /* __WIN__ */
}
/*******************************************************************************
@ -678,10 +674,6 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
}
/* Calcuate the waiting period. */
#ifdef __WIN__
abstime.tv.i64 = start_ts.tv.i64 + (__int64)wait_timeout_ * TIME_THOUSAND * 10;
abstime.max_timeout_msec= (long)wait_timeout_;
#else
unsigned long long diff_nsecs =
start_ts.tv_nsec + (unsigned long long)wait_timeout_ * TIME_MILLION;
abstime.tv_sec = start_ts.tv_sec;
@ -691,7 +683,6 @@ int ReplSemiSyncMaster::commitTrx(const char* trx_wait_binlog_name,
diff_nsecs -= TIME_BILLION;
}
abstime.tv_nsec = diff_nsecs;
#endif /* __WIN__ */
/* In semi-synchronous replication, we wait until the binlog-dump
* thread has received the reply on the relevant binlog segment from the

View File

@ -28,7 +28,7 @@ IF(WIN32)
log_client.cc common.cc handshake.cc)
MYSQL_ADD_PLUGIN(authentication_windows_client ${PLUGIN_SOURCES} ${HEADERS}
LINK_LIBRARUES Secur32
LINK_LIBRARIES Secur32
MODULE_ONLY)
ENDIF(WIN32)

View File

@ -100,6 +100,7 @@ TARGET_LINK_LIBRARIES(sql ${MYSQLD_STATIC_PLUGIN_LIBS}
IF(WIN32)
SET(MYSQLD_SOURCE main.cc nt_servc.cc nt_servc.h message.rc)
TARGET_LINK_LIBRARIES(sql psapi)
ELSE()
SET(MYSQLD_SOURCE main.cc ${DTRACE_PROBES_ALL})
ENDIF()

View File

@ -2753,6 +2753,7 @@ extern "C" char *my_demangle(const char *mangled_name, int *status)
}
#endif
extern const char *optimizer_switch_names[];
extern "C" sig_handler handle_segfault(int sig)
{
@ -2859,7 +2860,6 @@ the thread stack. Please read http://dev.mysql.com/doc/mysql/en/linux.html\n\n",
fprintf(stderr, "Status: %s\n", kreason);
fprintf(stderr, "Optimizer switch: ");
extern const char *optimizer_switch_names[];
ulonglong optsw= global_system_variables.optimizer_switch;
for (uint i= 0; optimizer_switch_names[i+1]; i++, optsw >>= 1)
{

View File

@ -59,7 +59,7 @@
#define EXTRA_DEBUG_fflush fflush
#else
static void inline EXTRA_DEBUG_fprintf(...) {}
static int EXTRA_DEBUG_fflush(...) {}
static int inline EXTRA_DEBUG_fflush(...) { return 0; }
#endif
#ifdef MYSQL_SERVER
#define MYSQL_SERVER_my_error my_error

View File

@ -3027,8 +3027,19 @@ int ha_federated::delete_all_rows()
}
/*
The idea with handler::store_lock() is the following:
Used to manually truncate the table via a delete of all rows in a table.
*/
int ha_federated::truncate()
{
return delete_all_rows();
}
/* The idea with handler::store_lock() is the following:
The statement decided which locks we should need for the table
for updates/deletes/inserts we get WRITE locks, for SELECT... we get

View File

@ -42,7 +42,7 @@ SET(ARIA_SOURCES ma_init.c ma_open.c ma_extra.c ma_info.c ma_rkey.c
)
MYSQL_ADD_PLUGIN(aria ${ARIA_SOURCES}
STORAGE_ENGINE
STORAGE_ENGINE STATIC_ONLY DEFAULT
RECOMPILE_FOR_EMBEDDED)
TARGET_LINK_LIBRARIES(aria myisam)

View File

@ -395,7 +395,7 @@ int main(int argc __attribute__((unused)),
pagecache_file_init(file1, &dummy_callback, &dummy_callback,
&dummy_fail_callback, &dummy_callback, NULL);
DBUG_PRINT("info", ("file1: %d", file1.file));
if (my_chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO, MYF(MY_WME)))
if (my_chmod(file1_name, 0777, MYF(MY_WME)))
exit(1);
my_pwrite(file1.file, (const uchar *)"test file", 9, 0, MYF(0));

View File

@ -265,7 +265,7 @@ int main(int argc __attribute__((unused)),
pagecache_file_init(file1, &dummy_callback, &dummy_callback,
&dummy_fail_callback, &dummy_callback, NULL);
DBUG_PRINT("info", ("file1: %d", file1.file));
if (my_chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO, MYF(MY_WME)))
if (my_chmod(file1_name, 0777, MYF(MY_WME)))
exit(1);
my_pwrite(file1.file, (const uchar*) "test file", 9, 0, MYF(0));

View File

@ -261,7 +261,7 @@ int main(int argc __attribute__((unused)),
pagecache_file_init(file1, &dummy_callback, &dummy_callback,
&dummy_fail_callback, &dummy_callback, NULL);
DBUG_PRINT("info", ("file1: %d", file1.file));
if (my_chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO, MYF(MY_WME)))
if (my_chmod(file1_name, 0777, MYF(MY_WME)))
exit(1);
my_pwrite(file1.file, (const uchar*) "test file", 9, 0, MYF(0));

View File

@ -792,7 +792,7 @@ int main(int argc __attribute__((unused)),
my_delete(file2_name, MYF(0));
DBUG_PRINT("info", ("file1: %d", file1.file));
if (my_chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO, MYF(MY_WME)))
if (my_chmod(file1_name, 0777, MYF(MY_WME)))
exit(1);
my_pwrite(file1.file, (const uchar*)"test file", 9, 0, MYF(MY_WME));

View File

@ -154,7 +154,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
pagecache_file_init(file1, &dummy_callback, &dummy_callback,
&dummy_fail_callback, maria_flush_log_for_page, NULL);
if (my_chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO, MYF(MY_WME)))
if (my_chmod(file1_name, 0777, MYF(MY_WME)))
exit(1);
{

View File

@ -15,12 +15,11 @@ IF(BOOST_OK)
ADD_DEFINITIONS(-DHAVE_OQGRAPH)
IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
ENDIF(MSVC)
IF(CMAKE_CXX_FLAGS)
ELSE(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
STRING(REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")
ENDIF()
ENDIF(MSVC)
MYSQL_ADD_PLUGIN(oqgraph ha_oqgraph.cc graphcore.cc STORAGE_ENGINE
MODULE_ONLY)

View File

@ -90,6 +90,5 @@ src/xt_config.h
src/xt_defs.h
src/xt_errno.h)
SET(PBXT_PLUGIN_STATIC "pbxt")
MYSQL_ADD_PLUGIN(pbxt ${PBXT_SOURCES} STORAGE_ENGINE)
MYSQL_ADD_PLUGIN(pbxt ${PBXT_SOURCES} STORAGE_ENGINE STATIC_ONLY)

View File

@ -26,8 +26,8 @@
#include <stdio.h>
#ifndef XT_WIN
#include <unistd.h>
#include <signal.h>
#endif
#include <signal.h>
#include <stdlib.h>
#ifndef DRIZZLED

View File

@ -45,22 +45,16 @@ xtPublic void xt_p_init_threading(void)
xtPublic int xt_p_set_normal_priority(pthread_t thr)
{
if (!SetThreadPriority (thr, THREAD_PRIORITY_NORMAL))
return GetLastError();
return 0;
}
xtPublic int xt_p_set_low_priority(pthread_t thr)
{
if (!SetThreadPriority (thr, THREAD_PRIORITY_LOWEST))
return GetLastError();
return 0;
}
xtPublic int xt_p_set_high_priority(pthread_t thr)
{
if (!SetThreadPriority (thr, THREAD_PRIORITY_HIGHEST))
return GetLastError();
return 0;
}
@ -401,31 +395,7 @@ xtPublic int xt_p_cond_timedwait(xt_cond_type *cond, xt_mutex_type *mt, struct t
xtPublic int xt_p_join(pthread_t thread, void **value)
{
DWORD exitcode;
while(1) {
switch (WaitForSingleObject(thread, 10000)) {
case WAIT_OBJECT_0:
return 0;
case WAIT_TIMEOUT:
/* Don't do this! According to the Win docs:
* _endthread automatically closes the thread handle
* (whereas _endthreadex does not). Therefore, when using
* _beginthread and _endthread, do not explicitly close the
* thread handle by calling the Win32 CloseHandle API.
CloseHandle(thread);
*/
/* This is done so that if the thread was not [yet] in the running
* state when this function was called we won't deadlock here.
*/
if (GetExitCodeThread(thread, &exitcode) && (exitcode == STILL_ACTIVE))
break;
return 0;
case WAIT_FAILED:
return GetLastError();
}
}
pthread_join(thread, value);
return 0;
}

View File

@ -1513,16 +1513,7 @@ xtPublic pthread_t xt_run_thread(XTThreadPtr self, XTThreadPtr child, void *(*st
data.td_started = FALSE;
data.td_thr = child;
data.td_start_routine = start_routine;
#ifdef XT_WIN
{
pthread_attr_t attr = { 0, 0, 0 };
attr.priority = THREAD_PRIORITY_NORMAL;
err = pthread_create(&child_thread, &attr, xt_thread_main, &data);
}
#else
err = pthread_create(&child_thread, NULL, xt_thread_main, &data);
#endif
if (err) {
xt_free_thread(child);
xt_throw_errno(XT_CONTEXT, err);

View File

@ -26,10 +26,10 @@
#include "field.h"
#include "item.h"
#include <mysqld_error.h>
#include <my_net.h>
#ifndef __WIN__
// UNIX-specific
#include <my_net.h>
#include <netdb.h>
#include <sys/un.h>
@ -39,8 +39,6 @@
#else
// Windows-specific
#include <io.h>
#define strcasecmp stricmp
#define snprintf _snprintf
#define RECV_FLAGS 0

View File

@ -259,5 +259,5 @@ IF(WITH_INNODB)
SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
ENDIF()
MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE
MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE DEFAULT
LINK_LIBRARIES ${ZLIB_LIBRARY})

View File

@ -29,6 +29,13 @@ Created 9/20/1997 Heikki Tuuri
#include "log0recv.ic"
#endif
#include "config.h"
#ifdef HAVE_ALLOCA_H
#include "alloca.h"
#else
#include "malloc.h"
#endif
#include "mem0mem.h"
#include "buf0buf.h"
#include "buf0flu.h"

View File

@ -37,7 +37,7 @@ Created 10/21/1995 Heikki Tuuri
#ifdef UNIV_NONINL
#include "os0file.ic"
#endif
#include "ha_prototypes.h"
#include "ut0mem.h"
#include "srv0srv.h"
#include "srv0start.h"
@ -1601,7 +1601,7 @@ try_again:
}
} else {
*success = TRUE;
if (os_aio_use_native_aio && ((attributes & FILE_FLAG_OVERLAPPED) != 0)) {
if (srv_use_native_aio && ((attributes & FILE_FLAG_OVERLAPPED) != 0)) {
ut_a(CreateIoCompletionPort(file, completion_port, 0, 0));
}
}
@ -4286,18 +4286,6 @@ os_aio_windows_handle(
ret = GetQueuedCompletionStatus(completion_port, &len, &key,
(OVERLAPPED **)&slot, INFINITE);
if (srv_recovery_stats && recv_recovery_is_on() && n_consecutive) {
mutex_enter(&(recv_sys->mutex));
if (slot->type == OS_FILE_READ) {
recv_sys->stats_read_io_pages += n_consecutive;
recv_sys->stats_read_io_consecutive[n_consecutive - 1]++;
} else if (slot->type == OS_FILE_WRITE) {
recv_sys->stats_write_io_pages += n_consecutive;
recv_sys->stats_write_io_consecutive[n_consecutive - 1]++;
}
mutex_exit(&(recv_sys->mutex));
}
/* If shutdown key was received, repost the shutdown message and exit */
if (ret && (key == IOCP_SHUTDOWN_KEY)) {
PostQueuedCompletionStatus(completion_port, 0, key, NULL);

View File

@ -136,20 +136,6 @@ UNIV_INTERN ulint srv_max_file_format_at_startup = DICT_TF_FORMAT_MAX;
/** Place locks to records only i.e. do not use next-key locking except
on duplicate key checking and foreign key checking */
UNIV_INTERN ibool srv_locks_unsafe_for_binlog = FALSE;
#ifdef __WIN__
/* Windows native condition variables. We use runtime loading / function
pointers, because they are not available on Windows Server 2003 and
Windows XP/2000.
We use condition for events on Windows if possible, even if os_event
resembles Windows kernel event object well API-wise. The reason is
performance, kernel objects are heavyweights and WaitForSingleObject() is a
performance killer causing calling thread to context switch. Besides, Innodb
is preallocating large number (often millions) of os_events. With kernel event
objects it takes a big chunk out of non-paged pool, which is better suited
for tasks like IO than for storing idle event objects. */
UNIV_INTERN ibool srv_use_native_conditions = FALSE;
#endif /* __WIN__ */
/* If this flag is TRUE, then we will use the native aio of the
OS (provided we compiled Innobase with it in), otherwise we will

View File

@ -1377,7 +1377,7 @@ innobase_start_or_create_for_mysql(void)
} else if (0 == ut_strcmp(srv_file_flush_method_str,
"async_unbuffered")) {
srv_win_file_flush_method = SRV_WIN_IO_UNBUFFERED;
os_aio_use_native_aio = TRUE;
srv_use_native_aio = TRUE;
#endif
} else {
ut_print_timestamp(stderr);

View File

@ -15,5 +15,3 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
ADD_LIBRARY(mytap tap.c)
MY_ADD_TESTS(t/basic)