mirror of
https://github.com/MariaDB/server.git
synced 2026-05-14 19:07:15 +02:00
Merge with MySQL 5.1.55
- Fixed some issues with partitions and connection_string, which also fixed lp:716890 "Pre- and post-recovery crash in Aria" - Fixed wrong assert in Aria Now need to merge with latest xtradb before pushing sql/ha_partition.cc: Ensure that m_ordered_rec_buffer is not freed before close. sql/mysqld.cc: Changed to use opt_stack_trace instead of opt_pstack. Removed references to pstack sql/partition_element.h: Ensure that connect_string is initialized storage/maria/ma_key_recover.c: Fixed wrong assert
This commit is contained in:
commit
58bb0769bd
1288 changed files with 22729 additions and 41591 deletions
|
|
@ -52,8 +52,8 @@ const char * NEAR globerrs[GLOBERRS]=
|
|||
"File '%s' (fileno: %d) was not closed",
|
||||
"Can't change ownership of the file '%s' (Errcode: %d)",
|
||||
"Can't change permissions of the file '%s' (Errcode: %d)",
|
||||
"Can't seek in file '%s' (Errcode: %d)"
|
||||
"Can't change mode for file '%s' to 0x%lx (Error: %d)",
|
||||
"Can't do seek on file '%s' (Errcode: %d)",
|
||||
"Warning: Can't copy ownership for file '%s' (Error: %d)"
|
||||
};
|
||||
|
||||
|
|
@ -98,8 +98,8 @@ void init_glob_errs()
|
|||
EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %d)";
|
||||
EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %d)";
|
||||
EE(EE_CANT_CHMOD) = "Can't change mode for file '%s' to 0x%lx (Error: %d)";
|
||||
EE(EE_CANT_SEEK) = "Can't do seek on file '%s' (Errcode: %d)";
|
||||
EE(EE_CANT_COPY_OWNERSHIP)= "Warning: Can't copy ownership for file '%s' (Error: %d)";
|
||||
EE(EE_CANT_SEEK) = "Can't seek in file '%s' (Errcode: %d)";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
138
mysys/my_fopen.c
138
mysys/my_fopen.c
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 2000 MySQL AB
|
||||
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
|
||||
Copyright (c) 1985-2011 Monty Program Ab
|
||||
|
||||
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
|
||||
|
|
@ -18,6 +19,10 @@
|
|||
#include <errno.h>
|
||||
#include "mysys_err.h"
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
extern int getosreldate(void);
|
||||
#endif
|
||||
|
||||
static void make_ftype(char * to,int flag);
|
||||
|
||||
/*
|
||||
|
|
@ -97,8 +102,137 @@ FILE *my_fopen(const char *filename, int flags, myf MyFlags)
|
|||
} /* my_fopen */
|
||||
|
||||
|
||||
/* Close a stream */
|
||||
#if defined(_WIN32)
|
||||
|
||||
static FILE *my_win_freopen(const char *path, const char *mode, FILE *stream)
|
||||
{
|
||||
int handle_fd, fd= _fileno(stream);
|
||||
HANDLE osfh;
|
||||
|
||||
DBUG_ASSERT(path && stream);
|
||||
|
||||
/* Services don't have stdout/stderr on Windows, so _fileno returns -1. */
|
||||
if (fd < 0)
|
||||
{
|
||||
if (!freopen(path, mode, stream))
|
||||
return NULL;
|
||||
|
||||
fd= _fileno(stream);
|
||||
}
|
||||
|
||||
if ((osfh= CreateFile(path, GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE |
|
||||
FILE_SHARE_DELETE, NULL,
|
||||
OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,
|
||||
NULL)) == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
if ((handle_fd= _open_osfhandle((intptr_t)osfh,
|
||||
_O_APPEND | _O_TEXT)) == -1)
|
||||
{
|
||||
CloseHandle(osfh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (_dup2(handle_fd, fd) < 0)
|
||||
{
|
||||
CloseHandle(osfh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_close(handle_fd);
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
#elif defined(__FreeBSD__)
|
||||
|
||||
/* No close operation hook. */
|
||||
|
||||
static int no_close(void *cookie __attribute__((unused)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
A hack around a race condition in the implementation of freopen.
|
||||
|
||||
The race condition steams from the fact that the current fd of
|
||||
the stream is closed before its number is used to duplicate the
|
||||
new file descriptor. This defeats the desired atomicity of the
|
||||
close and duplicate of dup2().
|
||||
|
||||
See PR number 79887 for reference:
|
||||
http://www.freebsd.org/cgi/query-pr.cgi?pr=79887
|
||||
*/
|
||||
|
||||
static FILE *my_freebsd_freopen(const char *path, const char *mode, FILE *stream)
|
||||
{
|
||||
int old_fd;
|
||||
FILE *result;
|
||||
|
||||
flockfile(stream);
|
||||
|
||||
old_fd= fileno(stream);
|
||||
|
||||
/* Use a no operation close hook to avoid having the fd closed. */
|
||||
stream->_close= no_close;
|
||||
|
||||
/* Relies on the implicit dup2 to close old_fd. */
|
||||
result= freopen(path, mode, stream);
|
||||
|
||||
/* If successful, the _close hook was replaced. */
|
||||
|
||||
if (result == NULL)
|
||||
close(old_fd);
|
||||
else
|
||||
funlockfile(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
Change the file associated with a file stream.
|
||||
|
||||
@param path Path to file.
|
||||
@param mode Mode of the stream.
|
||||
@param stream File stream.
|
||||
|
||||
@note
|
||||
This function is used to redirect stdout and stderr to a file and
|
||||
subsequently to close and reopen that file for log rotation.
|
||||
|
||||
@retval A FILE pointer on success. Otherwise, NULL.
|
||||
*/
|
||||
|
||||
FILE *my_freopen(const char *path, const char *mode, FILE *stream)
|
||||
{
|
||||
FILE *result;
|
||||
|
||||
#if defined(_WIN32)
|
||||
result= my_win_freopen(path, mode, stream);
|
||||
#elif defined(__FreeBSD__)
|
||||
/*
|
||||
XXX: Once the fix is ported to the stable releases, this should
|
||||
be dependent upon the specific FreeBSD versions. Check at:
|
||||
http://www.freebsd.org/cgi/query-pr.cgi?pr=79887
|
||||
*/
|
||||
if (getosreldate() > 900027)
|
||||
result= freopen(path, mode, stream);
|
||||
else
|
||||
result= my_freebsd_freopen(path, mode, stream);
|
||||
#else
|
||||
result= freopen(path, mode, stream);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Close a stream */
|
||||
int my_fclose(FILE *fd, myf MyFlags)
|
||||
{
|
||||
int err,file;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ int my_getncpus()
|
|||
GetSystemInfo(&sysinfo);
|
||||
ncpus= sysinfo.dwNumberOfProcessors;
|
||||
#else
|
||||
/* unknown so play safe: assume SMP and forbid uniprocessor build */
|
||||
/* unknown so play safe: assume SMP and forbid uniprocessor build */
|
||||
ncpus= 2;
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
/* Copyright (C) 2004 MySQL AB
|
||||
/* Copyright (c) 2004, 2011, Oracle and/or its affiliates.
|
||||
Copyright (c) 2009-2011 Monty Program Ab
|
||||
|
||||
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
|
||||
|
|
@ -170,7 +171,13 @@ ulonglong my_micro_time_and_time(time_t *time_arg)
|
|||
|
||||
pthread_mutex_lock(&THR_LOCK_time);
|
||||
cur_gethrtime= gethrtime();
|
||||
if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS)
|
||||
/*
|
||||
Due to bugs in the Solaris (x86) implementation of gethrtime(),
|
||||
the time returned by it might not be monotonic. Don't use the
|
||||
cached time(2) value if this is a case.
|
||||
*/
|
||||
if ((prev_gethrtime > cur_gethrtime) ||
|
||||
((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS))
|
||||
{
|
||||
cur_time= time(0);
|
||||
prev_gethrtime= cur_gethrtime;
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ my_off_t my_tell(File fd, myf MyFlags)
|
|||
my_errno= errno;
|
||||
if (MyFlags & MY_WME)
|
||||
my_error(EE_CANT_SEEK, MYF(0), my_filename(fd), my_errno);
|
||||
DBUG_PRINT("error", ("tell: %lu errno: %d", (ulong) pos, my_errno));
|
||||
}
|
||||
DBUG_PRINT("exit",("pos: %lu", (ulong) pos));
|
||||
DBUG_RETURN((my_off_t) pos);
|
||||
|
|
|
|||
|
|
@ -121,8 +121,7 @@ int my_is_symlink(const char *filename __attribute__((unused)))
|
|||
(including the end \0)
|
||||
*/
|
||||
|
||||
int my_realpath(char *to, const char *filename,
|
||||
myf MyFlags __attribute__((unused)))
|
||||
int my_realpath(char *to, const char *filename, myf MyFlags)
|
||||
{
|
||||
#if defined(HAVE_REALPATH) && !defined(HAVE_BROKEN_REALPATH)
|
||||
int result=0;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,11 @@
|
|||
#include <unistd.h>
|
||||
#include <strings.h>
|
||||
|
||||
#ifdef __linux__
|
||||
#include <ctype.h> /* isprint */
|
||||
#include <sys/syscall.h> /* SYS_gettid */
|
||||
#endif
|
||||
|
||||
#if HAVE_EXECINFO_H
|
||||
#include <execinfo.h>
|
||||
#endif
|
||||
|
|
@ -46,10 +51,99 @@ void my_init_stacktrace()
|
|||
#endif
|
||||
}
|
||||
|
||||
void my_safe_print_str(const char* name, const char* val, int max_len)
|
||||
#ifdef __linux__
|
||||
|
||||
static void print_buffer(char *buffer, size_t count)
|
||||
{
|
||||
char *heap_end= (char*) sbrk(0);
|
||||
fprintf(stderr, "%s at %p ", name, val);
|
||||
for (; count && *buffer; --count)
|
||||
{
|
||||
int c= (int) *buffer++;
|
||||
fputc(isprint(c) ? c : ' ', stderr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Access the pages of this process through /proc/self/task/<tid>/mem
|
||||
in order to safely print the contents of a memory address range.
|
||||
|
||||
@param addr The address at the start of the memory region.
|
||||
@param max_len The length of the memory region.
|
||||
|
||||
@return Zero on success.
|
||||
*/
|
||||
static int safe_print_str(const char *addr, int max_len)
|
||||
{
|
||||
int fd;
|
||||
pid_t tid;
|
||||
off_t offset;
|
||||
ssize_t nbytes= 0;
|
||||
size_t total, count;
|
||||
char buf[256];
|
||||
|
||||
tid= (pid_t) syscall(SYS_gettid);
|
||||
|
||||
sprintf(buf, "/proc/self/task/%d/mem", tid);
|
||||
|
||||
if ((fd= open(buf, O_RDONLY)) < 0)
|
||||
return -1;
|
||||
|
||||
/* Ensure that off_t can hold a pointer. */
|
||||
compile_time_assert(sizeof(off_t) >= sizeof(intptr));
|
||||
|
||||
total= max_len;
|
||||
offset= (intptr) addr;
|
||||
|
||||
/* Read up to the maximum number of bytes. */
|
||||
while (total)
|
||||
{
|
||||
count= min(sizeof(buf), total);
|
||||
|
||||
if ((nbytes= pread(fd, buf, count, offset)) < 0)
|
||||
{
|
||||
/* Just in case... */
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
/* Advance offset into memory. */
|
||||
total-= nbytes;
|
||||
offset+= nbytes;
|
||||
addr+= nbytes;
|
||||
|
||||
/* Output the printable characters. */
|
||||
print_buffer(buf, nbytes);
|
||||
|
||||
/* Break if less than requested... */
|
||||
if ((count - nbytes))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Output a new line if something was printed. */
|
||||
if (total != (size_t) max_len)
|
||||
fputc('\n', stderr);
|
||||
|
||||
if (nbytes == -1)
|
||||
fprintf(stderr, "Can't read from address %p: %m.\n", addr);
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void my_safe_print_str(const char* val, int max_len)
|
||||
{
|
||||
char *heap_end;
|
||||
|
||||
#ifdef __linux__
|
||||
if (!safe_print_str(val, max_len))
|
||||
return;
|
||||
#endif
|
||||
|
||||
heap_end= (char*) sbrk(0);
|
||||
|
||||
if (!PTR_SANE(val))
|
||||
{
|
||||
|
|
@ -57,7 +151,6 @@ void my_safe_print_str(const char* name, const char* val, int max_len)
|
|||
return;
|
||||
}
|
||||
|
||||
fprintf(stderr, "= ");
|
||||
for (; max_len && PTR_SANE(val) && *val; --max_len)
|
||||
fputc(*val++, stderr);
|
||||
fputc('\n', stderr);
|
||||
|
|
@ -318,6 +411,9 @@ end:
|
|||
/* Produce a core for the thread */
|
||||
void my_write_core(int sig)
|
||||
{
|
||||
#ifdef HAVE_gcov
|
||||
extern void __gcov_flush(void);
|
||||
#endif
|
||||
signal(sig, SIG_DFL);
|
||||
#ifdef HAVE_gcov
|
||||
/*
|
||||
|
|
@ -325,7 +421,6 @@ void my_write_core(int sig)
|
|||
information from this process, causing gcov output to be incomplete.
|
||||
So we force the writing of coverage information here before terminating.
|
||||
*/
|
||||
extern void __gcov_flush(void);
|
||||
__gcov_flush();
|
||||
#endif
|
||||
pthread_kill(pthread_self(), sig);
|
||||
|
|
@ -655,10 +750,9 @@ void my_write_core(int unused)
|
|||
}
|
||||
|
||||
|
||||
void my_safe_print_str(const char *name, const char *val, int len)
|
||||
void my_safe_print_str(const char *val, int len)
|
||||
{
|
||||
fprintf(stderr,"%s at %p", name, val);
|
||||
__try
|
||||
__try
|
||||
{
|
||||
fprintf(stderr,"=%.*s\n", len, val);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
* Multithreaded Demo Source
|
||||
*
|
||||
* Copyright (C) 1995 by Sun Microsystems, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* This file is a product of SunSoft, Inc. and is provided for
|
||||
* unrestricted use provided that this legend is included on all
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue