Commit 1b340658 authored by unknown's avatar unknown

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

into  quadxeon.mysql.com:/benchmarks/ext3/TOSAVE/tsmith/bk/maint/mar07/stage2/50
parents 242e5529 9713d81f
......@@ -17,7 +17,7 @@ noinst_SCRIPTS = Support/generate-text-files.pl
EXTRA_DIST = $(noinst_SCRIPTS) manual.chm mysql.info INSTALL-BINARY
TXT_FILES= ../INSTALL-SOURCE ../INSTALL-WIN-SOURCE ../EXCEPTIONS-CLIENT \
TXT_FILES= ../INSTALL-SOURCE ../INSTALL-WIN-SOURCE \
INSTALL-BINARY ../support-files/MacOSX/ReadMe.txt
all-local: $(TXT_FILES)
......@@ -55,9 +55,6 @@ GT = $(srcdir)/Support/generate-text-files.pl
INSTALL-BINARY: $(srcdir)/mysql.info $(GT)
perl -w $(GT) $(srcdir)/mysql.info "installing-binary" "installing-source" > $@
../EXCEPTIONS-CLIENT: $(srcdir)/mysql.info $(GT)
perl -w $(GT) $(srcdir)/mysql.info "mysql-floss-license-exception" "function-index" > $@
../support-files/MacOSX/ReadMe.txt: $(srcdir)/mysql.info $(GT)
perl -w $(GT) $(srcdir)/mysql.info "mac-os-x-installation" "netware-installation" > $@
......
MySQL FLOSS License Exception
The MySQL AB Exception for Free/Libre and Open Source
Software-only Applications Using MySQL Client Libraries (the
"FLOSS Exception").
Version 0.5, 30 August 2006
Exception Intent
We want specified Free/Libre and Open Source Software (``FLOSS'')
applications to be able to use specified GPL-licensed MySQL client
libraries (the ``Program'') despite the fact that not all FLOSS
licenses are compatible with version 2 of the GNU General Public
License (the ``GPL'').
Legal Terms and Conditions
As a special exception to the terms and conditions of version 2.0
of the GPL:
1. You are free to distribute a Derivative Work that is formed
entirely from the Program and one or more works (each, a
"FLOSS Work") licensed under one or more of the licenses
listed below in section 1, as long as:
a. You obey the GPL in all respects for the Program and the
Derivative Work, except for identifiable sections of the
Derivative Work which are not derived from the Program,
and which can reasonably be considered independent and
separate works in themselves,
b. all identifiable sections of the Derivative Work which
are not derived from the Program, and which can
reasonably be considered independent and separate works
in themselves,
i. are distributed subject to one of the FLOSS licenses
listed below, and
ii. the object code or executable form of those sections
are accompanied by the complete corresponding
machine-readable source code for those sections on
the same medium and under the same FLOSS license as
the corresponding object code or executable forms of
those sections, and
c. any works which are aggregated with the Program or with a
Derivative Work on a volume of a storage or distribution
medium in accordance with the GPL, can reasonably be
considered independent and separate works in themselves
which are not derivatives of either the Program, a
Derivative Work or a FLOSS Work.
If the above conditions are not met, then the Program may only
be copied, modified, distributed or used under the terms and
conditions of the GPL or another valid licensing option from
MySQL AB.
2. FLOSS License List
License name Version(s)/Copyright Date
Academic Free License 2.0
Apache Software License 1.0/1.1/2.0
Apple Public Source License 2.0
Artistic license From Perl 5.8.0
BSD license "July 22 1999"
Common Public License 1.0
GNU Library or "Lesser" General Public License (LGPL) 2.0/2.1
Jabber Open Source License 1.0
MIT license ---
Mozilla Public License (MPL) 1.0/1.1
Open Software License 2.0
OpenSSL license (with original SSLeay license) "2003" ("1998")
PHP License 3.0
Python license (CNRI Python License) ---
Python Software Foundation License 2.1.1
Sleepycat License "1999"
University of Illinois/NCSA Open Source License ---
W3C License "2001"
X11 License "2001"
Zlib/libpng License ---
Zope Public License 2.0
Due to the many variants of some of the above licenses, we
require that any version follow the 2003 version of the Free
Software Foundation's Free Software Definition
(http://www.gnu.org/philosophy/free-sw.html) or version 1.9 of
the Open Source Definition by the Open Source Initiative
(http://www.opensource.org/docs/definition.php).
3. Definitions
a. Terms used, but not defined, herein shall have the
meaning provided in the GPL.
b. Derivative Work means a derivative work under copyright
law.
4. Applicability: This FLOSS Exception applies to all Programs
that contain a notice placed by MySQL AB saying that the
Program may be distributed under the terms of this FLOSS
Exception. If you create or distribute a work which is a
Derivative Work of both the Program and any other work
licensed under the GPL, then this FLOSS Exception is not
available for that work; thus, you must remove the FLOSS
Exception notice from that work and comply with the GPL in all
respects, including by retaining all GPL notices. You may
choose to redistribute a copy of the Program exclusively under
the terms of the GPL by removing the FLOSS Exception notice
from that copy of the Program, provided that the copy has
never been modified by you or any third party.
Appendix A. Qualified Libraries and Packages
The following is a non-exhaustive list of libraries and packages
which are covered by the FLOSS License Exception. Please note that
this appendix is provided merely as an additional service to
specific FLOSS projects wishing to simplify licensing information
for their users. Compliance with one of the licenses noted under
the "FLOSS license list" section remains a prerequisite.
Package Name Qualifying License and Version
Apache Portable Runtime (APR) Apache Software License 2.0
......@@ -903,32 +903,26 @@ Global
{62E85884-3ACF-4F4C-873B-60B878147890}.Release.ActiveCfg = Release|Win32
{62E85884-3ACF-4F4C-873B-60B878147890}.Release.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.classic.ActiveCfg = classic|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.classic.Build.0 = classic|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.classic nt.ActiveCfg = classic|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.classic nt.Build.0 = classic|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Debug.ActiveCfg = Debug|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Debug.Build.0 = Debug|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_Classic.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_Classic.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_Debug.ActiveCfg = Debug|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_Debug.Build.0 = Debug|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_Pro.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_Pro.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_ProGPL.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_ProGPL.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_Release.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Embedded_Release.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Max.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Max.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Max nt.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Max nt.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.nt.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.nt.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.pro.ActiveCfg = pro|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.pro.Build.0 = pro|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.pro gpl.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.pro gpl.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.pro gpl nt.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.pro gpl nt.Build.0 = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.pro nt.ActiveCfg = pro|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.pro nt.Build.0 = pro|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Release.ActiveCfg = Release|Win32
{37D9BA79-302E-4582-A545-CB5FF7982EA3}.Release.Build.0 = Release|Win32
{89F24ECE-9953-40EF-BDF4-B41F5631E92B}.classic.ActiveCfg = classic|Win32
{89F24ECE-9953-40EF-BDF4-B41F5631E92B}.classic.Build.0 = classic|Win32
{89F24ECE-9953-40EF-BDF4-B41F5631E92B}.classic nt.ActiveCfg = classic|Win32
......@@ -1011,32 +1005,26 @@ Global
{AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Release.ActiveCfg = Release|Win32
{AD95DAD3-6DB9-4F8B-A345-7A39A83AAD3A}.Release.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.classic.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.classic.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.classic nt.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.classic nt.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Debug.ActiveCfg = Debug|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Debug.Build.0 = Debug|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_Classic.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_Classic.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_Debug.ActiveCfg = Debug|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_Debug.Build.0 = Debug|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_Pro.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_Pro.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_ProGPL.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_ProGPL.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_Release.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Embedded_Release.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Max.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Max.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Max nt.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Max nt.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.nt.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.nt.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.pro.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.pro.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.pro gpl.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.pro gpl.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.pro gpl nt.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.pro gpl nt.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.pro nt.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.pro nt.Build.0 = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Release.ActiveCfg = Release|Win32
{94B86159-C581-42CD-825D-C69CBC237E5C}.Release.Build.0 = Release|Win32
{3737BFE2-EF25-464F-994D-BD28A9F84528}.classic.ActiveCfg = classic|Win32
{3737BFE2-EF25-464F-994D-BD28A9F84528}.classic.Build.0 = classic|Win32
{3737BFE2-EF25-464F-994D-BD28A9F84528}.classic nt.ActiveCfg = classic|Win32
......@@ -1303,10 +1291,15 @@ Global
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.classic nt.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Debug.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_Classic.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_Classic.Build.0 = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_Debug.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_Debug.Build.0 = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_Pro.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_Pro.Build.0 = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_ProGPL.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_ProGPL.Build.0 = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_Release.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Embedded_Release.Build.0 = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Max.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.Max nt.ActiveCfg = Release|Win32
{6F01B69C-B1A5-4C45-B3A9-744E1EB0BED5}.nt.ActiveCfg = Release|Win32
......
......@@ -446,7 +446,7 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert IGNORE into t1 values ('Garbage');
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
drop table t1;
create table t1 (fl geometry);
create table t1 (fl geometry not null);
insert into t1 values (1);
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert into t1 values (1.11);
......@@ -454,5 +454,5 @@ ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert into t1 values ("qwerty");
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert into t1 values (pointfromtext('point(1,1)'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
ERROR 23000: Column 'fl' cannot be null
drop table t1;
......@@ -143,7 +143,8 @@ BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \
extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \
myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \
myisam/myisam_ftdump$BS \
sql/mysqld$BS sql/mysql_tzinfo_to_sql$BS \
sql/mysqld$BS sql/mysqld-debug$BS \
sql/mysql_tzinfo_to_sql$BS \
server-tools/instance-manager/mysqlmanager$BS \
client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
client/mysqldump$BS client/mysqlimport$BS \
......
......@@ -3114,8 +3114,8 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
ex.skip_lines = skip_lines;
List<Item> field_list;
thd->main_lex.select_lex.context.resolve_in_table_list_only(&tables);
set_fields(tables.db, field_list, &thd->main_lex.select_lex.context);
thd->lex->select_lex.context.resolve_in_table_list_only(&tables);
set_fields(tables.db, field_list, &thd->lex->select_lex.context);
thd->variables.pseudo_thread_id= thread_id;
if (net)
{
......
......@@ -1600,18 +1600,6 @@ static void network_init(void)
#endif /*!EMBEDDED_LIBRARY*/
void MYSQLerror(const char *s)
{
THD *thd=current_thd;
char *yytext= (char*) thd->lex->tok_start;
/* "parse error" changed into "syntax error" between bison 1.75 and 1.875 */
if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
s=ER(ER_SYNTAX_ERROR);
my_printf_error(ER_PARSE_ERROR, ER(ER_PARSE_ERROR), MYF(0), s,
(yytext ? (char*) yytext : ""),
thd->lex->yylineno);
}
#ifndef EMBEDDED_LIBRARY
/*
......
......@@ -166,14 +166,10 @@ Open_tables_state::Open_tables_state(ulong version_arg)
}
/*
Pass nominal parameters to Statement constructor only to ensure that
the destructor works OK in case of error. The main_mem_root will be
re-initialized in init().
*/
THD::THD()
:Statement(CONVENTIONAL_EXECUTION, 0, ALLOC_ROOT_MIN_BLOCK_SIZE, 0),
:Statement(&main_lex, &main_mem_root, CONVENTIONAL_EXECUTION,
/* statement id */ 0),
Open_tables_state(refresh_version),
lock_id(&main_lock_id),
user_time(0), in_sub_stmt(0), global_read_lock(0), is_fatal_error(0),
......@@ -184,6 +180,12 @@ THD::THD()
{
ulong tmp;
/*
Pass nominal parameters to init_alloc_root only to ensure that
the destructor works OK in case of an error. The main_mem_root
will be re-initialized in init_for_queries().
*/
init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
stmt_arena= this;
thread_stack= 0;
db= 0;
......@@ -477,6 +479,7 @@ THD::~THD()
#ifndef DBUG_OFF
dbug_sentry= THD_SENTRY_GONE;
#endif
free_root(&main_mem_root, MYF(0));
DBUG_VOID_RETURN;
}
......@@ -1623,18 +1626,17 @@ void Query_arena::cleanup_stmt()
Statement functions
*/
Statement::Statement(enum enum_state state_arg, ulong id_arg,
ulong alloc_block_size, ulong prealloc_size)
:Query_arena(&main_mem_root, state_arg),
Statement::Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
enum enum_state state_arg, ulong id_arg)
:Query_arena(mem_root_arg, state_arg),
id(id_arg),
set_query_id(1),
lex(&main_lex),
lex(lex_arg),
query(0),
query_length(0),
cursor(0)
{
name.str= NULL;
init_sql_alloc(&main_mem_root, alloc_block_size, prealloc_size);
}
......@@ -1676,7 +1678,7 @@ void Statement::restore_backup_statement(Statement *stmt, Statement *backup)
void THD::end_statement()
{
/* Cleanup SQL processing state to resuse this statement in next query. */
/* Cleanup SQL processing state to reuse this statement in next query. */
lex_end(lex);
delete lex->result;
lex->result= 0;
......@@ -1717,12 +1719,6 @@ void THD::restore_active_arena(Query_arena *set, Query_arena *backup)
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));
}
C_MODE_START
......
......@@ -753,8 +753,10 @@ class Query_arena
class Server_side_cursor;
/*
State of a single command executed against this connection.
/**
@class Statement
@brief State of a single command executed against this connection.
One connection can contain a lot of simultaneously running statements,
some of which could be:
- prepared, that is, contain placeholders,
......@@ -772,10 +774,6 @@ class Statement: public ilink, public Query_arena
Statement(const Statement &rhs); /* not implemented: */
Statement &operator=(const Statement &rhs); /* non-copyable */
public:
/* FIXME: these must be protected */
MEM_ROOT main_mem_root;
LEX main_lex;
/*
Uniquely identifies each statement object in thread scope; change during
statement lifetime. FIXME: must be const
......@@ -819,10 +817,10 @@ class Statement: public ilink, public Query_arena
public:
/* This constructor is called for backup statements */
Statement() { clear_alloc_root(&main_mem_root); }
Statement() {}
Statement(enum enum_state state_arg, ulong id_arg,
ulong alloc_block_size, ulong prealloc_size);
Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg,
enum enum_state state_arg, ulong id_arg);
virtual ~Statement();
/* Assign execution context (note: not all members) of given stmt to self */
......@@ -834,7 +832,7 @@ class Statement: public ilink, public Query_arena
};
/*
/**
Container for all statements created/used in a connection.
Statements in Statement_map have unique Statement::id (guaranteed by id
assignment in Statement::Statement)
......@@ -914,6 +912,10 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state);
bool xid_cache_insert(XID_STATE *xid_state);
void xid_cache_delete(XID_STATE *xid_state);
/**
@class Security_context
@brief A set of THD members describing the current authenticated user.
*/
class Security_context {
public:
......@@ -943,7 +945,7 @@ class Security_context {
};
/*
/**
A registry for item tree transformations performed during
query optimization. We register only those changes which require
a rollback to re-execute a prepared statement or stored procedure
......@@ -954,7 +956,7 @@ struct Item_change_record;
typedef I_List<Item_change_record> Item_change_list;
/*
/**
Type of prelocked mode.
See comment for THD::prelocked_mode for complete description.
*/
......@@ -963,7 +965,7 @@ enum prelocked_mode_type {NON_PRELOCKED= 0, PRELOCKED= 1,
PRELOCKED_UNDER_LOCK_TABLES= 2};
/*
/**
Class that holds information about tables which were opened and locked
by the thread. It is also used to save/restore this information in
push_open_tables_state()/pop_open_tables_state().
......@@ -1048,14 +1050,17 @@ class Open_tables_state
}
};
/* class to save context when executing a function or trigger */
/**
@class Sub_statement_state
@brief Used to save context when executing a function or trigger
*/
/* Defines used for Sub_statement_state::in_sub_stmt */
#define SUB_STMT_TRIGGER 1
#define SUB_STMT_FUNCTION 2
class Sub_statement_state
{
public:
......@@ -1114,7 +1119,8 @@ class Internal_error_handler
};
/*
/**
@class THD
For each client connection we create a separate thread with THD serving as
a thread/connection descriptor
*/
......@@ -1726,6 +1732,22 @@ class THD :public Statement,
private:
/** The current internal error handler for this thread, or NULL. */
Internal_error_handler *m_internal_handler;
/**
The lex to hold the parsed tree of conventional (non-prepared) queries.
Whereas for prepared and stored procedure statements we use an own lex
instance for each new query, for conventional statements we reuse
the same lex. (@see mysql_parse for details).
*/
LEX main_lex;
/**
This memory root is used for two purposes:
- for conventional queries, to allocate structures stored in main_lex
during parsing, and allocate runtime data (execution plan, etc.)
during execution.
- for prepared queries, only to allocate runtime data. The parsed
tree itself is reused between executions and thus is stored elsewhere.
*/
MEM_ROOT main_mem_root;
};
......
......@@ -1648,6 +1648,36 @@ void st_select_lex::print_limit(THD *thd, String *str)
}
}
/**
@brief Restore the LEX and THD in case of a parse error.
This is a clean up call that is invoked by the Bison generated
parser before returning an error from MYSQLparse. If your
semantic actions manipulate with the global thread state (which
is a very bad practice and should not normally be employed) and
need a clean-up in case of error, and you can not use %destructor
rule in the grammar file itself, this function should be used
to implement the clean up.
*/
void st_lex::cleanup_lex_after_parse_error(THD *thd)
{
/*
Delete sphead for the side effect of restoring of the original
LEX state, thd->lex, thd->mem_root and thd->free_list if they
were replaced when parsing stored procedure statements. We
will never use sphead object after a parse error, so it's okay
to delete it only for the sake of the side effect.
TODO: make this functionality explicit in sp_head class.
Sic: we must nullify the member of the main lex, not the
current one that will be thrown away
*/
if (thd->lex->sphead)
{
delete thd->lex->sphead;
thd->lex->sphead= NULL;
}
}
/*
Initialize (or reset) Query_tables_list object.
......
......@@ -1182,6 +1182,10 @@ typedef struct st_lex : public Query_tables_list
{
return context_stack.head();
}
/*
Restore the LEX and THD in case of a parse error.
*/
static void cleanup_lex_after_parse_error(THD *thd);
void reset_n_backup_query_tables_list(Query_tables_list *backup);
void restore_backup_query_tables_list(Query_tables_list *backup);
......
......@@ -4517,9 +4517,6 @@ mysql_execute_command(THD *thd)
clean up the environment.
*/
create_sp_error:
lex->unit.cleanup();
delete lex->sphead;
lex->sphead= 0;
if (sp_result != SP_OK )
goto error;
send_ok(thd);
......@@ -4890,9 +4887,6 @@ mysql_execute_command(THD *thd)
/* Conditionally writes to binlog. */
res= mysql_create_or_drop_trigger(thd, all_tables, 1);
/* We don't care about trigger body after this point */
delete lex->sphead;
lex->sphead= 0;
break;
}
case SQLCOM_DROP_TRIGGER:
......@@ -5915,15 +5909,7 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
else
#endif
{
if (thd->net.report_error)
{
if (thd->lex->sphead)
{
delete thd->lex->sphead;
thd->lex->sphead= NULL;
}
}
else
if (! thd->net.report_error)
{
/*
Binlog logs a string starting from thd->query and having length
......@@ -5943,7 +5929,6 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
query_cache_end_of_result(thd);
}
}
lex->unit.cleanup();
}
else
{
......@@ -5951,19 +5936,14 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
DBUG_PRINT("info",("Command aborted. Fatal_error: %d",
thd->is_fatal_error));
/*
The first thing we do after parse error is freeing sp_head to
ensure that we have restored original memroot.
*/
if (thd->lex->sphead)
{
/* Clean up after failed stored procedure/function */
delete thd->lex->sphead;
thd->lex->sphead= NULL;
}
query_cache_abort(&thd->net);
lex->unit.cleanup();
}
if (thd->lex->sphead)
{
delete thd->lex->sphead;
thd->lex->sphead= 0;
}
lex->unit.cleanup();
thd->proc_info="freeing items";
thd->end_statement();
thd->cleanup_after_query();
......
......@@ -99,9 +99,12 @@ class Select_fetch_protocol_prep: public select_send
#endif
};
/******************************************************************************
Prepared_statement: a statement that can contain placeholders
******************************************************************************/
/****************************************************************************/
/**
@class Prepared_statement
@brief Prepared_statement: a statement that can contain placeholders
*/
class Prepared_statement: public Statement
{
......@@ -141,6 +144,16 @@ class Prepared_statement: public Statement
bool execute(String *expanded_query, bool open_cursor);
/* Destroy this statement */
bool deallocate();
private:
/**
Store the parsed tree of a prepared statement here.
*/
LEX main_lex;
/**
The memory root to allocate parsed tree elements (instances of Item,
SELECT_LEX and other classes).
*/
MEM_ROOT main_mem_root;
};
......@@ -2034,6 +2047,7 @@ void mysql_sql_stmt_prepare(THD *thd)
delete stmt;
DBUG_VOID_RETURN;
}
if (thd->stmt_map.insert(thd, stmt))
{
/* The statement is deleted and an error is set if insert fails */
......@@ -2629,17 +2643,18 @@ Select_fetch_protocol_prep::send_data(List<Item> &fields)
****************************************************************************/
Prepared_statement::Prepared_statement(THD *thd_arg, Protocol *protocol_arg)
:Statement(INITIALIZED, ++thd_arg->statement_id_counter,
thd_arg->variables.query_alloc_block_size,
thd_arg->variables.query_prealloc_size),
:Statement(&main_lex, &main_mem_root,
INITIALIZED, ++thd_arg->statement_id_counter),
thd(thd_arg),
result(thd_arg),
protocol(protocol_arg),
param_array(0),
param_count(0),
last_errno(0),
flags((uint) IS_IN_USE)
flags((uint) IS_IN_USE)
{
init_alloc_root(&main_mem_root, thd_arg->variables.query_alloc_block_size,
thd_arg->variables.query_prealloc_size);
*last_error= '\0';
}
......@@ -2688,6 +2703,7 @@ Prepared_statement::~Prepared_statement()
*/
free_items();
delete lex->result;
free_root(&main_mem_root, MYF(0));
DBUG_VOID_RETURN;
}
......@@ -2703,6 +2719,7 @@ void Prepared_statement::cleanup_stmt()
DBUG_ENTER("Prepared_statement::cleanup_stmt");
DBUG_PRINT("enter",("stmt: %p", this));
DBUG_ASSERT(lex->sphead == 0);
/* The order is important */
lex->unit.cleanup();
cleanup_items(free_list);
......@@ -2789,15 +2806,6 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
error= MYSQLparse((void *)thd) || thd->is_fatal_error ||
thd->net.report_error || init_param_array(this);
/*
The first thing we do after parse error is freeing sp_head to
ensure that we have restored original memroot.
*/
if (error && lex->sphead)
{
delete lex->sphead;
lex->sphead= NULL;
}
/*
While doing context analysis of the query (in check_prepared_statement)
we allocate a lot of additional memory: for open tables, JOINs, derived
......@@ -2823,12 +2831,18 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
if (error == 0)
error= check_prepared_statement(this, name.str != 0);
/* Free sp_head if check_prepared_statement() failed. */
if (error && lex->sphead)
/*
Currently CREATE PROCEDURE/TRIGGER/EVENT are prohibited in prepared
statements: ensure we have no memory leak here if by someone tries
to PREPARE stmt FROM "CREATE PROCEDURE ..."
*/
DBUG_ASSERT(lex->sphead == NULL || error != 0);
if (lex->sphead)
{
delete lex->sphead;
lex->sphead= NULL;
}
lex_end(lex);
cleanup_stmt();
thd->restore_backup_statement(this, &stmt_backup);
......
......@@ -983,11 +983,8 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db,
thd->spcont= 0;
if (MYSQLparse((void *)thd) || thd->is_fatal_error)
{
/*
Free lex associated resources.
QQ: Do we really need all this stuff here ?
*/
delete lex.sphead;
/* Currently sphead is always deleted in case of a parse error */
DBUG_ASSERT(lex.sphead == 0);
goto err_with_lex_cleanup;
}
......
This diff is collapsed.
......@@ -605,6 +605,7 @@ fi
%doc %attr(644, root, man) %{_mandir}/man1/mysqlman.1*
%doc %attr(644, root, man) %{_mandir}/man8/mysqlmanager.8*
%doc %attr(644, root, man) %{_mandir}/man1/mysql.server.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysqltest.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_tzinfo_to_sql.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql_zap.1*
%doc %attr(644, root, man) %{_mandir}/man1/perror.1*
......@@ -693,24 +694,35 @@ fi
%files ndb-tools
%defattr(-,root,root,0755)
%attr(755, root, root) %{_bindir}/ndb_config
%attr(755, root, root) %{_bindir}/ndb_desc
%attr(755, root, root) %{_bindir}/ndb_error_reporter
%attr(755, root, root) %{_bindir}/ndb_mgm
%attr(755, root, root) %{_bindir}/ndb_restore
%attr(755, root, root) %{_bindir}/ndb_waiter
%attr(755, root, root) %{_bindir}/ndb_select_all
%attr(755, root, root) %{_bindir}/ndb_select_count
%attr(755, root, root) %{_bindir}/ndb_desc
%attr(755, root, root) %{_bindir}/ndb_show_tables
%attr(755, root, root) %{_bindir}/ndb_test_platform
%attr(755, root, root) %{_bindir}/ndb_config
%attr(755, root, root) %{_bindir}/ndb_error_reporter
%attr(755, root, root) %{_bindir}/ndb_size.pl
%attr(755, root, root) %{_bindir}/ndb_test_platform
%attr(755, root, root) %{_bindir}/ndb_waiter
%attr(-, root, root) %{_datadir}/mysql/ndb_size.tmpl
%doc %attr(644, root, man) %{_mandir}/man1/ndb_config.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_desc.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_error_reporter.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_select_all.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_select_count.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_show_tables.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_size.pl.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_waiter.1*
%files ndb-extra
%defattr(-,root,root,0755)
%attr(755, root, root) %{_bindir}/ndb_delete_all
%attr(755, root, root) %{_bindir}/ndb_drop_index
%attr(755, root, root) %{_bindir}/ndb_drop_table
%attr(755, root, root) %{_bindir}/ndb_delete_all
%doc %attr(644, root, man) %{_mandir}/man1/ndb_delete_all.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_drop_index.1*
%doc %attr(644, root, man) %{_mandir}/man1/ndb_drop_table.1*
%files devel
%defattr(-, root, root, 0755)
......@@ -756,6 +768,9 @@ fi
%attr(755, root, root) %{_bindir}/mysqltestmanager
%attr(755, root, root) %{_bindir}/mysqltestmanager-pwgen
%attr(755, root, root) %{_bindir}/mysqltestmanagerc
%doc %attr(644, root, man) %{_mandir}/man1/mysql_client_test.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql-stress-test.pl.1*
%doc %attr(644, root, man) %{_mandir}/man1/mysql-test-run.pl.1*
%files Max
%defattr(-, root, root, 0755)
......@@ -770,6 +785,10 @@ fi
# itself - note that they must be ordered by date (important when
# merging BK trees)
%changelog
* Fri Mar 02 2007 Joerg Bruehe <joerg@mysql.com>
- Add several man pages for NDB which are now created.
* Wed Jan 31 2007 Daniel Fischer <df@mysql.com>
- add MTR_BUILD_THREAD=auto to test runs.
......
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