Merge marko@bk-internal.mysql.com:/home/bk/mysql-5.0

into hundin.mysql.fi:/home/marko/mysql-5.0-current
This commit is contained in:
marko@hundin.mysql.fi 2005-06-22 13:40:31 +03:00
commit 2af4f441fe
32 changed files with 109 additions and 130 deletions

View File

@ -710,3 +710,30 @@ fi
]) ])
AC_DEFUN([MYSQL_CHECK_CXX_VERSION], [
case $SYSTEM_TYPE in
*netware*)
CXX_VERSION=`$CXX -version | grep -i version`
;;
*)
CXX_VERSION=`$CXX --version | sed 1q`
if test $? -ne "0" -o -z "$CXX_VERSION"
then
CXX_VERSION=`$CXX -V 2>&1|sed 1q` # trying harder for Sun and SGI
fi
if test $? -ne "0" -o -z "$CXX_VERSION"
then
CXX_VERSION=`$CXX -v 2>&1|sed 1q` # even harder for Alpha
fi
if test $? -ne "0" -o -z "$CXX_VERSION"
then
CXX_VERSION=""
fi
esac
if test "$CXX_VERSION"
then
AC_MSG_CHECKING("C++ compiler version");
AC_MSG_RESULT("$CXX $CXX_VERSION")
fi
AC_SUBST(CXX_VERSION)
])

View File

@ -195,25 +195,8 @@ then
else else
CC_VERSION="" CC_VERSION=""
fi fi
case $SYSTEM_TYPE in
*netware*)
CXX_VERSION=`$CXX -version | grep -i version`
;;
*)
CXX_VERSION=`$CXX --version | sed 1q`
CXX_VERSION=${CXX_VERSION:-`$CXX -V|sed 1q`} # trying harder for Sun and SGI
CXX_VERSION=${CXX_VERSION:-`$CXX -V 2>&1|sed 1q`} # even harder for Alpha
;;
esac
if test $? -eq "0"
then
AC_MSG_CHECKING("C++ compiler version");
AC_MSG_RESULT("$CXX $CXX_VERSION")
else
CXX_VERSION=""
fi
AC_SUBST(CXX_VERSION)
AC_SUBST(CC_VERSION) AC_SUBST(CC_VERSION)
MYSQL_CHECK_CXX_VERSION
# Fix for sgi gcc / sgiCC which tries to emulate gcc # Fix for sgi gcc / sgiCC which tries to emulate gcc
if test "$CC" = "sgicc" if test "$CC" = "sgicc"
@ -367,18 +350,18 @@ then
# Disable exceptions as they seams to create problems with gcc and threads. # Disable exceptions as they seams to create problems with gcc and threads.
# mysqld doesn't use run-time-type-checking, so we disable it. # mysqld doesn't use run-time-type-checking, so we disable it.
CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti" CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti"
CXXFLAGS="$CXXFLAGS -DEXPLICIT_TEMPLATE_INSTANTIATION" AC_DEFINE([HAVE_EXPLICIT_TEMPLATE_INSTANTIATION],
[1], [Defined by configure. Use explicit template instantiation.])
fi fi
case $CXX_VERSION in case $CXX_VERSION in
MIPSpro*) MIPSpro*)
CXXFLAGS="$CXXFLAGS -no_prelink -DEXPLICIT_TEMPLATE_INSTANTIATION" AR=$CXX
ARFLAGS="-ar -o"
;; ;;
Compaq*) *Forte*)
CXXFLAGS="$CXXFLAGS -nopt -DEXPLICIT_TEMPLATE_INSTANTIATION" AR=$CXX
;; ARFLAGS="-xar -o"
Forte*)
CXXFLAGS="$CXXFLAGS -instance=explicit -DEXPLICIT_TEMPLATE_INSTANTIATION"
esac esac
# Avoid bug in fcntl on some versions of linux # Avoid bug in fcntl on some versions of linux

View File

@ -971,7 +971,7 @@ x509* PemToDer(const char* fname, CertType type)
} // namespace } // namespace
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
namespace yaSSL { namespace yaSSL {
template void ysDelete<DiffieHellman::DHImpl>(DiffieHellman::DHImpl*); template void ysDelete<DiffieHellman::DHImpl>(DiffieHellman::DHImpl*);
template void ysDelete<Integer::IntegerImpl>(Integer::IntegerImpl*); template void ysDelete<Integer::IntegerImpl>(Integer::IntegerImpl*);
@ -989,6 +989,6 @@ template void ysDelete<RMD::RMDImpl>(RMD::RMDImpl*);
template void ysDelete<SHA::SHAImpl>(SHA::SHAImpl*); template void ysDelete<SHA::SHAImpl>(SHA::SHAImpl*);
template void ysDelete<MD5::MD5Impl>(MD5::MD5Impl*); template void ysDelete<MD5::MD5Impl>(MD5::MD5Impl*);
} }
#endif // EXPLICIT_TEMPLATE_INSTANTIATION #endif // HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
#endif // !USE_CRYPTOPP_LIB #endif // !USE_CRYPTOPP_LIB

View File

@ -8,7 +8,7 @@
#include "ripemd.hpp" #include "ripemd.hpp"
#include "openssl/ssl.h" #include "openssl/ssl.h"
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
#if !defined(USE_CRYPTOPP_LIB) #if !defined(USE_CRYPTOPP_LIB)
namespace TaoCrypt { namespace TaoCrypt {
template class HMAC<MD5>; template class HMAC<MD5>;

View File

@ -24,6 +24,7 @@
* draft along with type conversion functions. * draft along with type conversion functions.
*/ */
#include "runtime.hpp"
#include "yassl_int.hpp" #include "yassl_int.hpp"
#include "handshake.hpp" #include "handshake.hpp"
#include "timer.hpp" #include "timer.hpp"
@ -1975,7 +1976,7 @@ X509_NAME* X509::GetSubject()
} // namespace } // namespace
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
namespace mySTL { namespace mySTL {
template yaSSL::yassl_int_cpp_local1::SumData for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData); template yaSSL::yassl_int_cpp_local1::SumData for_each<mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData>(mySTL::list<yaSSL::input_buffer*>::iterator, mySTL::list<yaSSL::input_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumData);
template yaSSL::yassl_int_cpp_local1::SumBuffer for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer); template yaSSL::yassl_int_cpp_local1::SumBuffer for_each<mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer>(mySTL::list<yaSSL::output_buffer*>::iterator, mySTL::list<yaSSL::output_buffer*>::iterator, yaSSL::yassl_int_cpp_local1::SumBuffer);

View File

@ -35,7 +35,7 @@ extern "C" {
#include <assert.h> #include <assert.h>
/* Disallow inline __cxa_pure_virtual() */ /* Disallow inline __cxa_pure_virtual() */
static int __cxa_pure_virtual() __attribute__((noinline)); static int __cxa_pure_virtual() __attribute__((noinline, used));
static int __cxa_pure_virtual() static int __cxa_pure_virtual()
{ {
// oops, pure virtual called! // oops, pure virtual called!

View File

@ -25,6 +25,10 @@
#ifndef TAO_CRYPT_TYPES_HPP #ifndef TAO_CRYPT_TYPES_HPP
#define TAO_CRYPT_TYPES_HPP #define TAO_CRYPT_TYPES_HPP
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
namespace TaoCrypt { namespace TaoCrypt {
// define this if running on a big-endian CPU // define this if running on a big-endian CPU

View File

@ -319,7 +319,7 @@ void AbstractRing::SimultaneousExponentiate(Integer *results,
} // namespace } // namespace
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
namespace mySTL { namespace mySTL {
template TaoCrypt::WindowSlider* uninit_copy<TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); template TaoCrypt::WindowSlider* uninit_copy<TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*);
template void destroy<TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*); template void destroy<TaoCrypt::WindowSlider*>(TaoCrypt::WindowSlider*, TaoCrypt::WindowSlider*);

View File

@ -23,6 +23,7 @@
/* dh.cpp implements Diffie-Hellman support /* dh.cpp implements Diffie-Hellman support
*/ */
#include "runtime.hpp"
#include "dh.hpp" #include "dh.hpp"
#include "asn.hpp" #include "asn.hpp"

View File

@ -20,6 +20,7 @@
*/ */
#include "runtime.hpp"
#include "dsa.hpp" #include "dsa.hpp"
#include "sha.hpp" #include "sha.hpp"
#include "asn.hpp" #include "asn.hpp"

View File

@ -3956,7 +3956,7 @@ Integer CRT(const Integer &xp, const Integer &p, const Integer &xq,
return p * (u * (xq-xp) % q) + xp; return p * (u * (xq-xp) % q) + xp;
} }
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
#ifndef TAOCRYPT_NATIVE_DWORD_AVAILABLE #ifndef TAOCRYPT_NATIVE_DWORD_AVAILABLE
template hword DivideThreeWordsByTwo<hword, Word>(hword*, hword, hword, Word*); template hword DivideThreeWordsByTwo<hword, Word>(hword*, hword, hword, Word*);
#endif #endif

View File

@ -21,6 +21,7 @@
/* based on Wei Dai's rsa.cpp from CryptoPP */ /* based on Wei Dai's rsa.cpp from CryptoPP */
#include "runtime.hpp"
#include "rsa.hpp" #include "rsa.hpp"
#include "asn.hpp" #include "asn.hpp"
#include "modarith.hpp" #include "modarith.hpp"

View File

@ -4,7 +4,7 @@
#include "vector.hpp" #include "vector.hpp"
#include "hash.hpp" #include "hash.hpp"
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
namespace TaoCrypt { namespace TaoCrypt {
#if defined(SSE2_INTRINSICS_AVAILABLE) #if defined(SSE2_INTRINSICS_AVAILABLE)
template AlignedAllocator<unsigned int>::pointer StdReallocate<unsigned int, AlignedAllocator<unsigned int> >(AlignedAllocator<unsigned int>&, unsigned int*, AlignedAllocator<unsigned int>::size_type, AlignedAllocator<unsigned int>::size_type, bool); template AlignedAllocator<unsigned int>::pointer StdReallocate<unsigned int, AlignedAllocator<unsigned int> >(AlignedAllocator<unsigned int>&, unsigned int*, AlignedAllocator<unsigned int>::size_type, AlignedAllocator<unsigned int>::size_type, bool);

View File

@ -38,7 +38,7 @@
Instansiate templates and static variables Instansiate templates and static variables
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List<create_field>; template class List<create_field>;
template class List_iterator<create_field>; template class List_iterator<create_field>;
#endif #endif

View File

@ -5410,7 +5410,7 @@ void Item_result_field::cleanup()
** Instantiate templates ** Instantiate templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List<Item>; template class List<Item>;
template class List_iterator<Item>; template class List_iterator<Item>;
template class List_iterator_fast<Item>; template class List_iterator_fast<Item>;

View File

@ -146,7 +146,7 @@ bool Cached_item_decimal::cmp()
** Instansiate templates ** Instansiate templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List<Cached_item>; template class List<Cached_item>;
template class List_iterator<Cached_item>; template class List_iterator<Cached_item>;
#endif #endif

View File

@ -7073,7 +7073,7 @@ static void create_pid_file()
Instantiate templates Instantiate templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
/* Used templates */ /* Used templates */
template class I_List<THD>; template class I_List<THD>;
template class I_List_iterator<THD>; template class I_List_iterator<THD>;

View File

@ -8918,7 +8918,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::dbug_dump(int indent, bool verbose)
** Instantiate templates ** Instantiate templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List<QUICK_RANGE>; template class List<QUICK_RANGE>;
template class List_iterator<QUICK_RANGE>; template class List_iterator<QUICK_RANGE>;
#endif #endif

View File

@ -3406,7 +3406,7 @@ bool process_key_caches(int (* func) (const char *name, KEY_CACHE *))
Used templates Used templates
****************************************************************************/ ****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List<set_var_base>; template class List<set_var_base>;
template class List_iterator_fast<set_var_base>; template class List_iterator_fast<set_var_base>;
template class I_List_iterator<NAMED_LIST>; template class I_List_iterator<NAMED_LIST>;

View File

@ -5002,7 +5002,7 @@ end:
} }
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class I_List_iterator<i_string>; template class I_List_iterator<i_string>;
template class I_List_iterator<i_string_pair>; template class I_List_iterator<i_string_pair>;
#endif #endif

View File

@ -310,7 +310,8 @@ sp_head::operator delete(void *ptr, size_t size)
sp_head::sp_head() sp_head::sp_head()
:Query_arena((bool)FALSE), m_returns_cs(NULL), m_has_return(FALSE), :Query_arena(&main_mem_root, INITIALIZED_FOR_SP),
m_returns_cs(NULL), m_has_return(FALSE),
m_simple_case(FALSE), m_multi_results(FALSE), m_in_handler(FALSE) m_simple_case(FALSE), m_multi_results(FALSE), m_in_handler(FALSE)
{ {
extern byte * extern byte *
@ -319,7 +320,6 @@ sp_head::sp_head()
*sp_lex_sp_key(const byte *ptr, uint *plen, my_bool first); *sp_lex_sp_key(const byte *ptr, uint *plen, my_bool first);
DBUG_ENTER("sp_head::sp_head"); DBUG_ENTER("sp_head::sp_head");
state= INITIALIZED_FOR_SP;
m_backpatch.empty(); m_backpatch.empty();
m_lex.empty(); m_lex.empty();
hash_init(&m_sptabs, system_charset_info, 0, 0, 0, sp_table_key, 0, 0); hash_init(&m_sptabs, system_charset_info, 0, 0, 0, sp_table_key, 0, 0);

View File

@ -79,6 +79,7 @@ class sp_head :private Query_arena
sp_head(const sp_head &); /* Prevent use of these */ sp_head(const sp_head &); /* Prevent use of these */
void operator=(sp_head &); void operator=(sp_head &);
MEM_ROOT main_mem_root;
public: public:
int m_type; // TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE int m_type; // TYPE_ENUM_FUNCTION or TYPE_ENUM_PROCEDURE

View File

@ -5325,7 +5325,7 @@ bool sp_grant_privileges(THD *thd, const char *sp_db, const char *sp_name,
Instantiate used templates Instantiate used templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List_iterator<LEX_COLUMN>; template class List_iterator<LEX_COLUMN>;
template class List_iterator<LEX_USER>; template class List_iterator<LEX_USER>;
template class List<LEX_COLUMN>; template class List<LEX_COLUMN>;

View File

@ -49,7 +49,7 @@ char internal_table_name[2]= "*";
** Instansiate templates ** Instansiate templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
/* Used templates */ /* Used templates */
template class List<Key>; template class List<Key>;
template class List_iterator<Key>; template class List_iterator<Key>;
@ -420,8 +420,6 @@ THD::~THD()
#ifndef DBUG_OFF #ifndef DBUG_OFF
dbug_sentry= THD_SENTRY_GONE; dbug_sentry= THD_SENTRY_GONE;
#endif #endif
/* Reset stmt_backup.mem_root to not double-free memory from thd.mem_root */
clear_alloc_root(&stmt_backup.main_mem_root);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -1474,52 +1472,6 @@ void select_dumpvar::cleanup()
} }
/*
Create arena for already constructed THD.
SYNOPSYS
Query_arena()
thd - thread for which arena is created
DESCRIPTION
Create arena for already existing THD using its variables as parameters
for memory root initialization.
*/
Query_arena::Query_arena(THD* thd)
:free_list(0), mem_root(&main_mem_root),
state(INITIALIZED)
{
init_sql_alloc(&main_mem_root,
thd->variables.query_alloc_block_size,
thd->variables.query_prealloc_size);
}
/*
Create arena and optionally initialize memory root.
SYNOPSYS
Query_arena()
init_mem_root - whenever we need to initialize memory root
DESCRIPTION
Create arena and optionally initialize memory root with minimal
possible parameters.
NOTE
We use this constructor when arena is part of THD, but reinitialize
its memory root in THD::init_for_queries() before execution of real
statements.
*/
Query_arena::Query_arena(bool init_mem_root)
:free_list(0), mem_root(&main_mem_root),
state(CONVENTIONAL_EXECUTION)
{
if (init_mem_root)
init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
}
Query_arena::Type Query_arena::type() const Query_arena::Type Query_arena::type() const
{ {
DBUG_ASSERT(0); /* Should never be called */ DBUG_ASSERT(0); /* Should never be called */
@ -1532,7 +1484,7 @@ Query_arena::Type Query_arena::type() const
*/ */
Statement::Statement(THD *thd) Statement::Statement(THD *thd)
:Query_arena(thd), :Query_arena(&main_mem_root, INITIALIZED),
id(++thd->statement_id_counter), id(++thd->statement_id_counter),
set_query_id(1), set_query_id(1),
allow_sum_func(0), allow_sum_func(0),
@ -1542,16 +1494,19 @@ Statement::Statement(THD *thd)
cursor(0) cursor(0)
{ {
name.str= NULL; name.str= NULL;
init_sql_alloc(&main_mem_root,
thd->variables.query_alloc_block_size,
thd->variables.query_prealloc_size);
} }
/* /*
This constructor is called when statement is a subobject of THD: This constructor is called when Statement is a parent of THD and
Some variables are initialized in THD::init due to locking problems for the backup statement. Some variables are initialized in
This statement object will be used to THD::init due to locking problems.
*/ */
Statement::Statement() Statement::Statement()
:Query_arena((bool)TRUE), :Query_arena(&main_mem_root, CONVENTIONAL_EXECUTION),
id(0), id(0),
set_query_id(1), set_query_id(1),
allow_sum_func(0), /* initialized later */ allow_sum_func(0), /* initialized later */
@ -1560,6 +1515,12 @@ Statement::Statement()
query_length(0), /* in alloc_query() */ query_length(0), /* in alloc_query() */
cursor(0) cursor(0)
{ {
/*
This is just to ensure that the destructor works correctly in
case of an error and the backup statement. The memory root will
be re-initialized in THD::init.
*/
init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
} }
@ -1631,16 +1592,6 @@ void Query_arena::restore_backup_item_arena(Query_arena *set, Query_arena *backu
set_item_arena(backup); set_item_arena(backup);
#ifndef DBUG_OFF #ifndef DBUG_OFF
backup_arena= 0; backup_arena= 0;
#endif
#ifdef NOT_NEEDED_NOW
/*
Reset backup mem_root to avoid its freeing.
Since Query_arena's mem_root is freed only when it is part of Statement
we need this only if we use some Statement's arena as backup storage.
But we do this only with THD::stmt_backup and this Statement is specially
handled in this respect. So this code is not really needed now.
*/
clear_alloc_root(&backup->mem_root);
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@ -1654,6 +1605,11 @@ void Query_arena::set_item_arena(Query_arena *set)
Statement::~Statement() Statement::~Statement()
{ {
/*
We must free `main_mem_root', not `mem_root' (pointer), to work
correctly if this statement is used as a backup statement,
for which `mem_root' may point to some other statement.
*/
free_root(&main_mem_root, MYF(0)); free_root(&main_mem_root, MYF(0));
} }

View File

@ -661,7 +661,6 @@ public:
itself to the list on creation (see Item::Item() for details)) itself to the list on creation (see Item::Item() for details))
*/ */
Item *free_list; Item *free_list;
MEM_ROOT main_mem_root;
MEM_ROOT *mem_root; // Pointer to current memroot MEM_ROOT *mem_root; // Pointer to current memroot
#ifndef DBUG_OFF #ifndef DBUG_OFF
bool backup_arena; bool backup_arena;
@ -680,21 +679,14 @@ public:
STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE STATEMENT, PREPARED_STATEMENT, STORED_PROCEDURE
}; };
Query_arena(MEM_ROOT *mem_root_arg, enum enum_state state_arg) :
free_list(0), mem_root(mem_root_arg), state(state_arg)
{}
/* /*
This constructor is used only when Query_arena is created as This constructor is used only when Query_arena is created as
backup storage for another instance of Query_arena. backup storage for another instance of Query_arena.
*/ */
Query_arena() {}; Query_arena() {};
/*
Create arena for already constructed THD using its variables as
parameters for memory root initialization.
*/
Query_arena(THD *thd);
/*
Create arena and optionally init memory root with minimal values.
Particularly used if Query_arena is part of Statement.
*/
Query_arena(bool init_mem_root);
virtual Type type() const; virtual Type type() const;
virtual ~Query_arena() {}; virtual ~Query_arena() {};
@ -708,6 +700,7 @@ public:
{ return state == PREPARED || state == EXECUTED; } { return state == PREPARED || state == EXECUTED; }
inline bool is_conventional() const inline bool is_conventional() const
{ return state == CONVENTIONAL_EXECUTION; } { return state == CONVENTIONAL_EXECUTION; }
inline gptr alloc(unsigned int size) { return alloc_root(mem_root,size); } inline gptr alloc(unsigned int size) { return alloc_root(mem_root,size); }
inline gptr calloc(unsigned int size) inline gptr calloc(unsigned int size)
{ {
@ -757,7 +750,8 @@ class Statement: public Query_arena
Statement(const Statement &rhs); /* not implemented: */ Statement(const Statement &rhs); /* not implemented: */
Statement &operator=(const Statement &rhs); /* non-copyable */ Statement &operator=(const Statement &rhs); /* non-copyable */
public: public:
/* FIXME: must be private */ /* FIXME: these must be protected */
MEM_ROOT main_mem_root;
LEX main_lex; LEX main_lex;
/* /*
@ -1388,7 +1382,7 @@ public:
already changed to use this arena. already changed to use this arena.
*/ */
if (!current_arena->is_conventional() && if (!current_arena->is_conventional() &&
mem_root != &current_arena->main_mem_root) mem_root != current_arena->mem_root)
{ {
set_n_backup_item_arena(current_arena, backup); set_n_backup_item_arena(current_arena, backup);
return current_arena; return current_arena;

View File

@ -2374,11 +2374,11 @@ void select_create::abort()
Instansiate templates Instansiate templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List_iterator_fast<List_item>; template class List_iterator_fast<List_item>;
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
template class I_List<delayed_insert>; template class I_List<delayed_insert>;
template class I_List_iterator<delayed_insert>; template class I_List_iterator<delayed_insert>;
template class I_List<delayed_row>; template class I_List<delayed_row>;
#endif /* EMBEDDED_LIBRARY */ #endif /* EMBEDDED_LIBRARY */
#endif /* EXPLICIT_TEMPLATE_INSTANTIATION */ #endif /* HAVE_EXPLICIT_TEMPLATE_INSTANTIATION */

View File

@ -138,7 +138,7 @@ void unmap_file(mapped_files *map)
** Instansiate templates ** Instansiate templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
/* Used templates */ /* Used templates */
template class I_List<mapped_files>; template class I_List<mapped_files>;
template class I_List_iterator<mapped_files>; template class I_List_iterator<mapped_files>;

View File

@ -2002,7 +2002,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length)
{ {
DBUG_PRINT("info",("Using READ_ONLY cursor")); DBUG_PRINT("info",("Using READ_ONLY cursor"));
if (!cursor && if (!cursor &&
!(cursor= stmt->cursor= new (&stmt->main_mem_root) Cursor())) !(cursor= stmt->cursor= new (stmt->mem_root) Cursor(thd)))
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
/* If lex->result is set, mysql_execute_command will use it */ /* If lex->result is set, mysql_execute_command will use it */
stmt->lex->result= &cursor->result; stmt->lex->result= &cursor->result;

View File

@ -1708,7 +1708,16 @@ JOIN::cleanup()
/************************* Cursor ******************************************/ /************************* Cursor ******************************************/
Cursor::Cursor(THD *thd)
:Query_arena(&main_mem_root, INITIALIZED),
join(0), unit(0)
{
/* We will overwrite it at open anyway. */
init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
}
void void
Cursor::init_from_thd(THD *thd) Cursor::init_from_thd(THD *thd)
{ {
@ -6277,7 +6286,7 @@ public:
COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {} COND_CMP(Item *a,Item_func *b) :and_level(a),cmp_func(b) {}
}; };
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class I_List<COND_CMP>; template class I_List<COND_CMP>;
template class I_List_iterator<COND_CMP>; template class I_List_iterator<COND_CMP>;
template class List<Item_func_match>; template class List<Item_func_match>;

View File

@ -372,6 +372,7 @@ class JOIN :public Sql_alloc
class Cursor: public Sql_alloc, public Query_arena class Cursor: public Sql_alloc, public Query_arena
{ {
MEM_ROOT main_mem_root;
JOIN *join; JOIN *join;
SELECT_LEX_UNIT *unit; SELECT_LEX_UNIT *unit;
@ -396,7 +397,7 @@ public:
void close(); void close();
void set_unit(SELECT_LEX_UNIT *unit_arg) { unit= unit_arg; } void set_unit(SELECT_LEX_UNIT *unit_arg) { unit= unit_arg; }
Cursor() :Query_arena(TRUE), join(0), unit(0) {} Cursor(THD *thd);
~Cursor(); ~Cursor();
}; };

View File

@ -1102,7 +1102,7 @@ public:
char *query; char *query;
}; };
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class I_List<thread_info>; template class I_List<thread_info>;
#endif #endif
@ -3879,7 +3879,7 @@ ST_SCHEMA_TABLE schema_tables[]=
}; };
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List_iterator_fast<char>; template class List_iterator_fast<char>;
template class List<char>; template class List<char>;
#endif #endif

View File

@ -2236,7 +2236,7 @@ const char *Field_iterator_view::name()
** Instansiate templates ** Instansiate templates
*****************************************************************************/ *****************************************************************************/
#ifdef EXPLICIT_TEMPLATE_INSTANTIATION #ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
template class List<String>; template class List<String>;
template class List_iterator<String>; template class List_iterator<String>;
#endif #endif