into mysql.com:/home/bk/MERGE/mysql-5.0-merge
client/mysqldump.c:
Auto merged
include/my_pthread.h:
Auto merged
mysql-test/r/mysqldump.result:
Auto merged
mysql-test/r/rpl_timezone.result:
Auto merged
mysql-test/t/disabled.def:
Auto merged
mysql-test/t/mysqldump.test:
Auto merged
mysys/my_thr_init.c:
Auto merged
sql/item_timefunc.cc:
Auto merged
sql/log.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/set_var.cc:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
Fixed compiler warnings (detected by VC++):
- Removed not used variables
- Added casts
- Fixed wrong assignments to bool
- Fixed wrong calls with bool arguments
- Added missing argument to store(longlong), which caused wrong store method to be called.
client/mysqldump.c:
Removed compiler warning
heap/hp_clear.c:
Removed compiler warning
include/my_global.h:
Removed compiler warning
include/my_tree.h:
Changed memory limits from int to ulong
(Allowed me to get rid of some compiler warnings)
myisam/mi_create.c:
Removed compiler warning
myisam/myisampack.c:
Removed compiler warning
mysys/base64.c:
Removed compiler warning
mysys/my_thr_init.c:
Fixed portability issue (detected on windows)
Added DBUG_ASSERT to detect if we call my_thread_end() too many times
Don't wait if THR_thread_count == -1 (error condition)
mysys/tree.c:
Removed compiler warning
sql/field.cc:
Removed compiler warning
Fixed wrong parameter to check_date()
Added missing argument to store(longlong)
sql/ha_archive.cc:
Removed compiler warning
sql/ha_federated.cc:
Removed compiler warning
sql/ha_innodb.cc:
Removed not used variable
sql/handler.cc:
Removed not used variable
Fixed wrong if (we didn't detect if rollback or commit failed). Not critical as value is not yet used
sql/item.cc:
Removed compiler warning
sql/item_func.cc:
Removed compiler warning
sql/item_strfunc.cc:
Removed compiler warning
sql/item_timefunc.cc:
Removed compiler warning
sql/log.cc:
Removed compiler warning
sql/mysql_priv.h:
Removed compiler warning
sql/opt_range.cc:
Removed compiler warning
sql/password.c:
Removed compiler warning
sql/set_var.cc:
Removed compiler warning
sql/slave.cc:
Removed compiler warning
sql/sp.cc:
Removed compiler warning
sql/sp_cache.cc:
Removed compiler warning
sql/sp_head.cc:
Removed compiler warning
Adjusted argument to reserve() to not use up too much memory that we are probably not going to need
sql/sql_acl.cc:
Added missing argument to store(longlong)
sql/sql_base.cc:
Removed compiler warning
sql/sql_db.cc:
Removed compiler warning
sql/sql_delete.cc:
Removed compiler warning
sql/sql_handler.cc:
Removed not used variable
sql/sql_lex.h:
Removed not used variable
sql/sql_prepare.cc:
Removed not used variable
sql/sql_rename.cc:
Removed not used variable
sql/sql_select.cc:
Fixed that select_options are not 'cut'
Removed some not used variables
Removed compiler warnings by adding cast
sql/sql_show.cc:
Removed not used variables
Added missing argument to store(longlong)
Removed compiler warnings
sql/sql_trigger.cc:
Removed not used variables
Added cast to remove compiler warnings
sql/sql_update.cc:
Fixed wrong set of bool variable
sql/sql_view.cc:
Removed not used variables
Added cast to get rid of compiler warnings
sql-common/client.c:
Fixed compiler warning
sql-common/my_time.c:
Fixed wrong argument to check_date()
Added casts to get rid of compiler warnings
sql/sql_yacc.yy:
Removed not used variable
sql/uniques.cc:
Changes memory size from uint to ulong
Added casts to get rid of compiler warnings
strings/ctype-simple.c:
Fixed cast to get rid of compiler warnings
Problem: when embedding a character string with introducer with charset X
into a SQL query which is generally in character set Y, the string constants
were escaped according to their own character set (i.e.X), then after reading
such a "mixed" query from binlog, the string constants were unescaped
using character set of the query (i.e. Y), instead of X, which gave wrong
results or even syntax errors with tricky charsets (e.g. sjis)
Fix: when embedding a string constant of charset X into a query of charset Y,
the string constant is now escaped according to character Y, instead of
its own character set X.
mysql-test/r/ctype_cp932_binlog.result:
Fixing test results.
sql/log_event.cc:
Using character set "csinfo" instead of the string character set.
sql/sp_head.cc:
- adding "thd" argument to sp_get_item_value()
to have access to thd->variables.character_set_client
- using character_set_client for escaping, instead of
the string character set
mysql-test/r/rpl_charset_sjis.result:
Adding test case
mysql-test/t/rpl_charset_sjis.test:
Adding test case
This patch reverts a change introduced by Bug 6951, which incorrectly
set thd->abort_on_warning for stored procedures.
As per internal discussions about the SQL_MODE=TRADITIONAL,
the correct behavior is to *not* abort on warnings even inside an INSERT/UPDATE
trigger.
Tests for Stored Procedures, Stored Functions, Triggers involving SQL_MODE
have been included or revised, to reflect the intended behavior.
(reposting approved patch, to work around source control issues, no review needed)
mysql-test/include/sp-vars.inc:
Tests for SQL_MODE='TRADITIONAL'
mysql-test/r/sp-vars.result:
Tests for SQL_MODE='TRADITIONAL'
mysql-test/r/sp.result:
Tests for SQL_MODE='TRADITIONAL'
mysql-test/r/trigger.result:
Tests for SQL_MODE='TRADITIONAL'
mysql-test/t/sp-vars.test:
Tests for SQL_MODE='TRADITIONAL'
mysql-test/t/sp.test:
Tests for SQL_MODE='TRADITIONAL'
mysql-test/t/trigger.test:
Tests for SQL_MODE='TRADITIONAL'
sql/sp_head.cc:
For SQL_MODE='TRADITIONAL',
thd->abort_on_warning should be set only when assigning a *column*
include/mysql_com.h:
USERNAME_LENGTH is changed to USERNAME_BYTE_LENGTH
mysql-test/r/ctype_utf8.result:
result fix
mysql-test/t/ctype_utf8.test:
test fix
sql/sp.cc:
NAME_LEN constant is changed to NAME_BYTE_LEN for database name buffer
USERNAME_LENGTH constant is changed to USERNAME_BYTE_LENGTH for user name buffer
sql/sp_head.cc:
NAME_LEN constant is changed to NAME_BYTE_LEN for database name buffer
USERNAME_LENGTH constant is changed to USERNAME_BYTE_LENGTH for user name buffer
sql/sql_acl.cc:
NAME_LEN constant is changed to NAME_BYTE_LEN for database name buffer
USERNAME_LENGTH constant is changed to USERNAME_BYTE_LENGTH for user name buffer
sql/sql_class.h:
NAME_LEN constant is changed to NAME_BYTE_LEN for database name buffer
sql/sql_parse.cc:
NAME_LEN constant is changed to NAME_BYTE_LEN for database name buffer
Function check_string_length() is fixed, now it check string lenght in symbols
sql/sql_repl.h:
NAME_LEN constant is changed to NAME_BYTE_LEN for database name buffer
USERNAME_LENGTH constant is changed to USERNAME_BYTE_LENGTH for user name buffer
erroneous check
Problem: Actually there were two problems in the server code. The check
for SQLCOM_FLUSH in SF/Triggers were not according to the existing
architecture which uses sp_get_flags_for_command() from sp_head.cc .
This function was also missing a check for SQLCOM_FLUSH which has a
problem combined with prelocking. This changeset fixes both of these
deficiencies as well as the erroneous check in
sp_head::is_not_allowed_in_function() which was a copy&paste error.
mysql-test/r/sp-error.result:
update result
mysql-test/r/trigger.result:
update result
mysql-test/t/sp-error.test:
FLUSH can create a problem with prelocking, hence it's disabled.
There is a better way to check this than a check in the parser.
Now we use sp_get_flags_for_command() and the error returned is
different.
mysql-test/t/trigger.test:
FLUSH can create a problem with prelocking, hence it's disabled.
There is a better way to check this than a check in the parser.
Now we use sp_get_flags_for_command() and the error returned is
different.
sql/sp_head.cc:
FLUSH and RESET are not allowed inside a SF/Trigger.
Because they don't imply a COMMIT sp_head::HAS_COMMIT_OR_ROLLBACK
cannot be used. Two new flags were introduced for that reason.
sql/sp_head.h:
Don't check m_type as this check is erroneous. This is probably
a copy and paste error when moving code from somewhere else. Another
fact which supports this was prefixing the enum value with the name
of class sp_head.
Adding two new flags HAS_SQLCOM_RESET and HAS_SQLCOM_FLUSH. The values
are 2048 and 4096 because in the 5.1 branch there are already new flags
which are with values up-to 1024.
sql/sql_parse.cc:
FLUSH can cause a problem with prelocking in SF/Trigger and
therefore is already disabled. RESET is also disabled because
is handled by the same code as FLUSH. We won't allow RESET inside
SF/Trigger at that stage without thorough analysis. The check for
them is already done in the parser by calling
is_not_allowed_in_function()
sql/sql_yacc.yy:
By listing SQLCOM_FLUSH as command which implies COMMIT
in sp_get_flags_for_command() the check in sql_yacc.yy is
obsolete.
can be not replicable.
Now CREATE statements for writing in the binlog are created as follows:
- the beginning of the statement is re-created;
- the rest of the statement is copied from the original query.
The problem appears when there is a version-specific comment (produced by
mysqldump), started in the re-created part of the statement and closed in the
copied part -- there is closing comment-parenthesis, but there is no opening
one.
The proper fix could be to re-create original statement, but we can not
implement it in 5.0. So, for 5.0 the fix is just to cut closing
comment-parenthesis. This technique is also used for SHOW CREATE PROCEDURE
statement (so we are able to reuse existing code).
mysql-test/r/rpl_sp.result:
Updated result file.
mysql-test/r/rpl_trigger.result:
Updated result file.
mysql-test/r/rpl_view.result:
Updated result file.
mysql-test/t/rpl_sp.test:
Added test case for BUG#20438.
mysql-test/t/rpl_trigger.test:
Added test case for BUG#20438.
mysql-test/t/rpl_view.test:
Added test case for BUG#20438.
sql/sp.cc:
Trim comments at the end.
sql/sp_head.cc:
Moved this code to the separate function to be re-used.
sql/sql_lex.cc:
Added a new function.
sql/sql_lex.h:
Added a new function.
sql/sql_trigger.cc:
Trim comments at the end.
sql/sql_view.cc:
Trim comments at the end.
Fix for BUG#16676: Database CHARSET not used for stored procedures
The problem in BUG#16211 is that CHARSET-clause of the return type for
stored functions is just ignored.
The problem in BUG#16676 is that if character set is not explicitly
specified for sp-variable, the server character set is used instead
of the database one.
The fix has two parts:
- always store CHARSET-clause of the return type along with the
type definition in mysql.proc.returns column. "Always" means that
CHARSET-clause is appended even if it has not been explicitly
specified in CREATE FUNCTION statement (this affects BUG#16211 only).
Storing CHARSET-clause if it is not specified is essential to avoid
changing character set if the database character set is altered in
the future.
NOTE: this change is not backward compatible with the previous releases.
- use database default character set if CHARSET-clause is not explicitly
specified (this affects both BUG#16211 and BUG#16676).
NOTE: this also breaks backward compatibility.
mysql-test/r/mysqldump.result:
Updated result file.
mysql-test/r/sp.result:
Updated result file.
mysql-test/t/sp.test:
Provided test cases for BUG#16211, BUG#16676.
sql/mysql_priv.h:
Added two convenient functions for work with databases.
sql/sp.cc:
1. Add CHARSET-clause to CREATE-statement if it has been explicitly specified.
2. Polishing -- provided some comments.
sql/sp_head.cc:
Use database charset as default charset of sp-variable.
sql/sp_head.h:
Move init_sp_name() out of init_strings().
sql/sql_db.cc:
Two new functions created:
- load_db_opt_by_name();
- check_db_dir_existence();
sql/sql_show.cc:
Eliminate duplicated code by using
check_db_dir_existence() and load_db_opt_by_name()
sql/sql_table.cc:
Eliminate duplicated code by using
check_db_dir_existence() and load_db_opt_by_name()
sql/sql_yacc.yy:
Call sp_head::init_sp_name() to initialize stored routine name.
context.
Routine arguments were evaluated in the security context of the routine
itself, not in the caller's context.
The bug is fixed the following way:
- Item_func_sp::find_and_check_access() has been split into two
functions: Item_func_sp::find_and_check_access() itself only
finds the function and check that the caller have EXECUTE privilege
on it. New function set_routine_security_ctx() changes security
context for SUID routines and checks that definer have EXECUTE
privilege too.
- new function sp_head::execute_trigger() is called from
Table_triggers_list::process_triggers() instead of
sp_head::execute_function(), and is effectively just as the
sp_head::execute_function() is, with all non-trigger related code
removed, and added trigger-specific security context switch.
- call to Item_func_sp::find_and_check_access() stays outside
of sp_head::execute_function(), and there is a code in
sql_parse.cc before the call to sp_head::execute_procedure() that
checks that the caller have EXECUTE privilege, but both
sp_head::execute_function() and sp_head::execute_procedure() call
set_routine_security_ctx() after evaluating their parameters,
and restore the context after the body is executed.
mysql-test/r/sp-security.result:
Add test case for bug#18630: Arguments of suid routine calculated
in wrong security context.
mysql-test/t/sp-security.test:
Add result for bug#18630: Arguments of suid routine calculated
in wrong security context.
sql/item_func.cc:
Do not change security context before executing the function, as it
will be changed after argument evaluation.
Do not change security context in Item_func_sp::find_and_check_access().
sql/item_func.h:
Change prototype for Item_func_sp::find_and_check_access().
sql/sp_head.cc:
Add set_routine_security_ctx() function.
Add sp_head::execute_trigger() method.
Change security context in sp_head::execute_trigger(), and in
sp_head::execute_function() and sp_head::execute_procedure()
after argument evaluation.
Move pop_all_cursors() call to sp_head::execute().
sql/sp_head.h:
Add declaration for sp_head::execute_trigger() and
set_routine_security_ctx().
sql/sql_parse.cc:
Do not change security context before executing the procedure, as it
will be changed after argument evaluation.
sql/sql_trigger.cc:
Call new sp_head::execute_trigger() instead of
sp_head::execute_function(), which is responsible to switch
security context.
SHOW CREATE PROCEDURE and SHOW CREATE FUNCTION are fixed as well as
INFORMATION_SCHEMA.ROUTINES.ROUTINE_NAME.
mysql-test/r/information_schema.result:
Add result for bug#20230.
mysql-test/t/information_schema.test:
Add test case for bug#20230.
sql/sp_head.cc:
Return NULL for routine definition if the user doesn't have enough
privilege to see it.
sql/sql_show.cc:
Make INFORMATION_SCHEMA.ROUTINES.ROUTINE_NAME NULL-able. Return
NULL if the user doesn't have enough privilege to see routine
definition.
into mysql.com:/opt/local/work/mysql-5.0-17199
mysql-test/r/create.result:
Auto merged
mysql-test/t/create.test:
Auto merged
sql/item_strfunc.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/slave.cc:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_db.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/sp.result:
SCCS merged
mysql-test/t/sp.test:
SCCS merged
Bug#19022 "Memory bug when switching db during trigger execution"
Bug#17199 "Problem when view calls function from another database."
Bug#18444 "Fully qualified stored function names don't work correctly in
SELECT statements"
Documentation note: this patch introduces a change in behaviour of prepared
statements.
This patch adds a few new invariants with regard to how THD::db should
be used. These invariants should be preserved in future:
- one should never refer to THD::db by pointer and always make a deep copy
(strmake, strdup)
- one should never compare two databases by pointer, but use strncmp or
my_strncasecmp
- TABLE_LIST object table->db should be always initialized in the parser or
by creator of the object.
For prepared statements it means that if the current database is changed
after a statement is prepared, the database that was current at prepare
remains active. This also means that you can not prepare a statement that
implicitly refers to the current database if the latter is not set.
This is not documented, and therefore needs documentation. This is NOT a
change in behavior for almost all SQL statements except:
- ALTER TABLE t1 RENAME t2
- OPTIMIZE TABLE t1
- ANALYZE TABLE t1
- TRUNCATE TABLE t1 --
until this patch t1 or t2 could be evaluated at the first execution of
prepared statement.
CURRENT_DATABASE() still works OK and is evaluated at every execution
of prepared statement.
Note, that in stored routines this is not an issue as the default
database is the database of the stored procedure and "use" statement
is prohibited in stored routines.
This patch makes obsolete the use of check_db_used (it was never used in the
old code too) and all other places that check for table->db and assign it
from THD::db if it's NULL, except the parser.
How this patch was created: THD::{db,db_length} were replaced with a
LEX_STRING, THD::db. All the places that refer to THD::{db,db_length} were
manually checked and:
- if the place uses thd->db by pointer, it was fixed to make a deep copy
- if a place compared two db pointers, it was fixed to compare them by value
(via strcmp/my_strcasecmp, whatever was approproate)
Then this intermediate patch was used to write a smaller patch that does the
same thing but without a rename.
TODO in 5.1:
- remove check_db_used
- deploy THD::set_db in mysql_change_db
See also comments to individual files.
mysql-test/r/create.result:
Modify the result file: a database can never be NULL.
mysql-test/r/ps.result:
Update test results (Bug#17199 et al)
mysql-test/r/sp.result:
Update test results (Bug#17199 et al)
mysql-test/t/create.test:
Update the id of the returned error.
mysql-test/t/ps.test:
Add test coverage for prepared statements and current database. In scope of
work on Bug#17199 "Problem when view calls function from another database."
mysql-test/t/sp.test:
Add a test case for Bug#17199 "Problem when view calls function from another
database." and Bug#18444 "Fully qualified stored function names don't work
correctly in SELECT statements". Test a complementary problem.
sql/item_strfunc.cc:
Touch the code that reads thd->db (cleanup).
sql/log_event.cc:
While we are at it, replace direct access to thd->db with a method.
Should simplify future conversion of THD::db to LEX_STRING.
sql/slave.cc:
While we are at it, replace direct access to thd->db with a method.
Should simplify future conversion of THD::db to LEX_STRING.
sql/slave.h:
Remove a declaration for a method that is used only in one module.
sql/sp.cc:
Rewrite sp_use_new_db: this is a cleanup that I needed in order to understand
this function and ensure that it has no bugs.
sql/sp.h:
Add a new declaration for sp_use_new_db (uses LEX_STRINGs) and a comment.
sql/sp_head.cc:
- drop sp_name_current_db_new - a creator of sp_name class that was used
when sp_name was created for an identifier without an explicitly initialized
database. Now we pass thd->db to constructor of sp_name right in the
parser.
- rewrite sp_head::init_strings: name->m_db is always set now
- use the new variant of sp_use_new_db
- we don't need to update thd->db with SP MEM_ROOT pointer anymore when
parsing a stored procedure, as noone will refer to it (yes!)
sql/sp_head.h:
- remove unneded methods and members
sql/sql_class.h:
- introduce 3 THD methods to work with THD::db:
.set_db to assign the current database
.reset_db to reset the current database (temporarily) or set it to NULL
.opt_copy_db_to - to deep-copy thd->db to a pointer if it's not NULL
sql/sql_db.cc:
While we are at it, replace direct access to thd->db with a method.
Should simplify future conversion of THD::db to LEX_STRING.
sql/sql_insert.cc:
- replace checks with asserts: table_list->db must be always set in the parser.
sql/sql_lex.h:
- add a comment
sql/sql_parse.cc:
- implement the invariant described in the changeset comment.
- remove juggling with lex->sphead in SQLCOM_CREATE_PROCEDURE:
now db_load_routine uses its own LEX object and doesn't damage the main
LEX.
- add DBUG_ASSERT(0) to unused "check_db_used"
sql/sql_table.cc:
- replace a check with an assert (table_ident->db)
sql/sql_trigger.cc:
While we are at it, replace direct access to thd->db with a method.
Should simplify future conversion of THD::db to LEX_STRING.
sql/sql_udf.cc:
- use thd->set_db instead of direct modification of to thd->db
sql/sql_view.cc:
- replace a check with an assert (view->db)
sql/sql_yacc.yy:
- make sure that we always copy table->db or name->db or ident->db or
select_lex->db from thd->db if the former is not set. If thd->db
is not set but is accessed, return an error.
sql/tztime.cc:
- be nice, never copy thd->db by pointer.
with PREPARE fails with weird error".
More generally, re-executing a stored procedure with a complex SP cursor query
could lead to a crash.
The cause of the problem was that SP cursor queries were not optimized
properly at first execution: their parse tree belongs to sp_instr_cpush,
not sp_instr_copen, and thus the tree was tagged "EXECUTED" when the
cursor was declared, not when it was opened. This led to loss of optimization
transformations performed at first execution, as sp_instr_copen saw that the
query is already "EXECUTED" and therefore either not ran first-execution
related blocks or wrongly rolled back the transformations caused by
first-execution code.
The fix is to update the state of the parsed tree only when the tree is
executed, as opposed to when the instruction containing the tree is executed.
Assignment if i->state is moved to reset_lex_and_exec_core.
mysql-test/r/sp.result:
Test results fixed (Bug#15217)
mysql-test/t/sp.test:
Add a test case for Bug#15217
sql/sp_head.cc:
Move assignment of stmt_arena->state to reset_lex_and_exec_core
not transaction-safe for stored procedures. Related to Bug#11151.
sql/sp_head.cc:
Guilhelm suggested that the "load data infile" command should be flagged as
not transaction-safe for stored procedures.
Stored procedure execution sometimes placed the address of auto variables
in the list of Item changes to undo in THD::rollback_item_tree_changes().
This could cause stack corruption.
sql/sp_head.cc:
Avoid storing address of auto variables in global rollback list, to
prevent stack memory corruption.
sql/sp_head.h:
Avoid storing address of auto variables in global rollback list, to
prevent stack memory corruption.
sql/sp_rcontext.cc:
Avoid storing address of auto variables in global rollback list, to
prevent stack memory corruption.
sql/sp_rcontext.h:
Avoid storing address of auto variables in global rollback list, to
prevent stack memory corruption.
sql/sql_class.cc:
Avoid storing address of auto variables in global rollback list, to
prevent stack memory corruption.
into mysql.com:/opt/local/work/mysql-5.0-runtime-merge
mysql-test/mysql-test-run.pl:
Auto merged
mysql-test/r/im_options_set.result:
Auto merged
mysql-test/r/im_options_unset.result:
Auto merged
mysql-test/r/trigger-grant.result:
Auto merged
sql/item.cc:
Auto merged
sql/item_func.cc:
Auto merged
sql/item_func.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/share/errmsg.txt:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
from within triggers
Add support for passing NEW.x as INOUT and OUT parameters to stored
procedures. Passing NEW.x as INOUT parameter requires SELECT and
UPDATE privileges on that column, and passing it as OUT parameter
requires only UPDATE privilege.
mysql-test/r/sp-error.result:
Update the result for new message.
mysql-test/r/trigger-grant.result:
Add result for bug#14635.
mysql-test/r/trigger.result:
Add result for bug#14635.
mysql-test/t/trigger-grant.test:
Add test case for bug#14635.
mysql-test/t/trigger.test:
Add test case for bug#14635.
sql/item.cc:
Add implementations of set_value() and set_required_privilege() methods
of Settable_routine_parameter interface.
Use Item_trigger_field::want_privilege instead of
Item_trigger_field::access_type.
Reset privileges on Item_trigger_field::cleanup().
sql/item.h:
Add interface class Settable_routine_parameter and interface query
method to Item class. Item_splocal and Item_trigger_field implement
this interface.
For Item_trigger_field:
- add read_only attribute and is_read_only() method.
- remove access_type and add original_privilege and want_privilege
instead.
- add set_value() method.
- add reset_privilege() method.
sql/item_func.cc:
Add implementations of set_value() method of Settable_routine_parameter
interface.
sql/item_func.h:
Item_func_get_user_var implements Settable_routine_parameter interface.
sql/share/errmsg.txt:
Update english ER_SP_NOT_VAR_ARG message.
sql/sp_head.cc:
Use Settable_routine_parameter interface for parameter update.
sql/sql_yacc.yy:
Set read_only and want_privilege members in Item_trigger_field
appropriately. For NEW.x trigger variable used in left-hand-side
of SET statement the latter is set to UPDATE_ACL, otherwise it is
set to SELECT_ACL (but see Item_trigger_field::set_required_privilege(),
where it may be updated to different value).
hog memory".
During each invocation of stored function or trigger some objects which
lifetime is one function call (e.g. sp_rcontext) were allocated on
arena/memroot of calling statement. This led to consumption of fixed amount
of memory for each function/trigger invocation and so statements which
involve lot of them were hogging memory. This in its return led to OOM
crashes or freezes.
This fix introduces new memroot and arena for objects which lifetime is
whole duration of function call. So all memory consumed by such objects
is freed at the end of function call.
sql/sp_head.cc:
sp_head::execute_function():
Introduced new memroot and arena for objects which lifetime is whole
duration of function call (e.g. sp_rcontext, sp_cursor). We can't
use caller's arena/memroot for those objects because in this case
some fixed amount of memory will be consumed for each function/trigger
invocation and so statements which involve lot of them will hog memory.
Got rid of param_values array to avoid excessive juggling with arenas.
into mysql.com:/home/tomash/src/mysql_ab/mysql-5.0-bug6951
mysql-test/r/trigger.result:
Auto merged
mysql-test/t/trigger.test:
Auto merged
sql/sp_head.cc:
Auto merged
While executing a trigger, we have to set thd->abort_on_warning to the value
it had at trigger creation time.
mysql-test/r/trigger.result:
Add result for bug#6951.
mysql-test/t/trigger.test:
Add test case for bug#6951.
sql/sp_head.cc:
While executing a trigger, set thd->abort_on_warning to the value it had at
trigger creation time.
Removed sp-goto.test, sp-goto.result and all (disabled) GOTO code.
Also removed some related code that's not needed any more (no possible
unresolved label references any more, so no need to check for them).
NB: Keeping the ER_SP_GOTO_IN_HNDLR in errmsg.txt; it might become useful
in the future, and removing it (and thus re-enumerating error codes)
might upset things. (Anything referring to explicit error codes.)
BitKeeper/deleted/.del-sp-goto.result~f343103c63f64b7a:
Delete: mysql-test/r/sp-goto.result
BitKeeper/deleted/.del-sp-goto.test~5054d3f729692d3d:
Delete: mysql-test/t/sp-goto.test
mysql-test/t/disabled.def:
sp-goto.test no longer exists.
sql/lex.h:
Removed (disabled) GOTO definitions.
sql/sp_head.cc:
Removed sp_head::check_backpatch() and simplified sp_head::backpatch().
Without GOTO, unresolved label references are not possible, so no need
to check for them.
sql/sp_head.h:
Removed sp_head::check_backpatch(). (Not needed with no GOTO)
sql/sp_pcontext.cc:
SP_LAB_GOTO was renamed to SP_LAB_IMPL
sql/sp_pcontext.h:
Removed SP_LAB_REF (no longer needed) and renamed SP_LAB_GOTO
to SP_LAB_IMPL, since it's only used for implicit labels now.
sql/sql_yacc.yy:
Removed GOTO symbols and (disabled) code, and the no longer needed
sp_head::check_backpatch() calls.
Also added comments, and fixing some coding style (mostly in comments too).
There are no functional changes, so no tests or documentation needed.
(This was originally part of a bugfix, but it was decided to not include this
in that patch; instead it's done separately.)
sql/sp_head.cc:
Renaming sp_pcontext members and methods; less cryptic and more consistent.
sql/sp_head.h:
Renaming sp_pcontext members and methods; less cryptic and more consistent.
sql/sp_pcontext.cc:
Renaming sp_pcontext members and methods; less cryptic and more consistent.
Also added comments, and fixing some coding style (mostly in comments too).
sql/sp_pcontext.h:
Renaming sp_pcontext members and methods; less cryptic and more consistent.
Also added comments, and fixing some coding style (mostly in comments too).
sql/sp_rcontext.cc:
Renaming sp_pcontext members and methods; less cryptic and more consistent.
sql/sp_rcontext.h:
Renaming sp_pcontext members and methods; less cryptic and more consistent.
sql/sql_yacc.yy:
Renaming sp_pcontext members and methods; less cryptic and more consistent.
Generating character set-independent quoting of strings for the
binary log when executing statements from inside stored procedure.
mysql-test/r/ctype_cp932_binlog.result:
Result change
mysql-test/t/ctype_cp932_binlog.test:
Adding check that string literals are written correctly for multi-byte
character sets.
sql/item.cc:
Cutting out character set-independent string escaping code and putting it
in a separate function.
sql/log_event.cc:
Adding characters set-independent code to separate function.
sql/mysql_priv.h:
Adding new function.
sql/sp_head.cc:
Escaping string value representing a string item.
Basically, this fix contains a test case and removing of a workaround
for replication. This fix became possible after pushing WL#2897
(Complete definer support in stored routines).
mysql-test/r/sp-security.result:
Updated the result file to contain results of test for BUG#13198.
mysql-test/t/sp-security.test:
Added a test case for BUG#13198.
sql/sp_head.cc:
Removed the workaround for replication, since WL#2897 is pushed and
now definer attribute/clause is fully supported in stored routines.
The idea is to add DEFINER-clause in CREATE PROCEDURE and CREATE FUNCTION
statements. Almost all support of definer in stored routines had been already
done before this patch.
NOTE: this patch changes behaviour of dumping stored routines in mysqldump.
Before this patch, mysqldump did not dump DEFINER-clause for stored routines
and this was documented behaviour. In order to get full information about stored
routines, one should have dumped mysql.proc table. This patch changes this
behaviour, so that DEFINER-clause is dumped.
Since DEFINER-clause is not supported in CREATE PROCEDURE | FUNCTION statements
before this patch, the clause is covered by additional version-specific comments.
client/mysqldump.c:
Updated the code for dumping stored routines: cover DEFINER-clause
into version-specific comment.
mysql-test/r/gis.result:
Updated result file after adding DEFINER-clause.
mysql-test/r/information_schema.result:
Updated result file after adding DEFINER-clause.
mysql-test/r/mysqldump.result:
Updated result file after adding DEFINER-clause.
mysql-test/r/rpl_ddl.result:
Updated result file after adding DEFINER-clause.
mysql-test/r/rpl_sp.result:
Updated result file after adding DEFINER-clause.
mysql-test/r/rpl_trigger.result:
Updated result file after adding DEFINER-clause.
mysql-test/r/sp-security.result:
Updated result file after adding DEFINER-clause.
mysql-test/r/sp.result:
Updated result file after adding DEFINER-clause.
mysql-test/r/sql_mode.result:
Updated result file after adding DEFINER-clause.
mysql-test/t/sp-security.test:
Updated result file after adding DEFINER-clause.
sql/sp.cc:
Added DEFINER-clause.
sql/sp_head.cc:
Added a new convenient variant of set_definer() operation.
sql/sp_head.h:
Updated result file after adding DEFINER-clause.
sql/sql_lex.h:
Renamed trigger_definition_begin into stmt_definition_begin to be used for
triggers and stored routines.
sql/sql_parse.cc:
Check DEFINER-clause.
sql/sql_trigger.cc:
Renamed trigger_definition_begin into stmt_definition_begin to be used for
triggers and stored routines.
sql/sql_yacc.yy:
Added DEFINER-clause.
into neptunus.(none):/home/msvensson/mysql/mysql-5.0
sql/sp_head.cc:
Auto merged
mysql-test/r/mysqldump.result:
Merge
mysql-test/t/mysqldump.test:
Merge
if the function, invoked in a non-binlogged caller (e.g. SELECT, DO), failed half-way on the master,
slave would stop and complain that error code between him and master mismatch.
To solve this, when a stored function is invoked in a non-binlogged caller (e.g. SELECT, DO), we binlog the function
call as SELECT instead of as DO (see revision comment of sp_head.cc for more).
And: minor wording change in the help text.
This cset will cause conflicts in 5.1, I'll merge.
mysql-test/r/rpl_sp.result:
result update
mysql-test/t/rpl_sp-slave.opt:
bug just fixed so option not needed
mysql-test/t/rpl_sp.test:
test for more half-failed functions with DO and SELECT, to test the bug of this changeset.
cleanup at the end.
sql/mysqld.cc:
function -> stored function (change suggested by Paul)
sql/sp_head.cc:
When a function updates data and is called from a non-binlogged statement (SELECT, DO), we binlog it
as SELECT myfunc(), and not DO myfunc() like before.
- Pass "in_comment" variable on to new lex in sp_head::reset_lex
- Add testcases for dumping and reloading trigger without BEGIN/END
mysql-test/r/mysqldump.result:
Update test result
mysql-test/t/mysqldump.test:
Add test for dumping trigger without begin/end, and test that the output from mysqldump can be reloaded.
sql/sp_head.cc:
If already in a comment before parsing a substatement, set in_comment in the new lex as well.
This will handle cases where the comment starts before the substatement, which is common in
output from mysqldump to mask away syntax not supported by earlier versions of MySQL.
Ex:
/*!50003 CREATE TRIGGER `tr1` BEFORE INSERT ON `t1` FOR EACH ROW
set new.created=now() */;
^=== sp_head::reset_lex is called when already in comment
into mysql.com:/extern/mysql/work/bug16568/mysql-5.0
mysql-test/r/sp.result:
Auto merged
mysql-test/t/sp.test:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sp_head.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
After trying multiple inheritance (to messy and hard make it work) and
sublassing jump_if_not (worked, but ugly), decided to on this solution
instead:
Inserting an abstract sp_instr_opt_meta class as parent for all instructions
with destinations makes it possible to handle a continuation pointer for
sp_instr_set_case_expr too.
Note: No special test case; the fix is captured by the changed behaviour of
bug14643_2, and bug14498_4 (formerly disabled), in sp.test.
mysql-test/r/sp.result:
Updated results for BUG#16568 (affects results for bug14643_2 and bug14498_4)
mysql-test/t/sp.test:
Enabled test bug14498_4 for BUG#16568.
sql/sp_head.cc:
Changed type of some parameters and variables (sp_instr_opt_meta instead of sp_instr_jump*).
Added consistency check of m_ip member in instructions in sp_head::show_routine_code().
Updated print() method of, and added opt_mark() and opt_move() methods to
sp_instr_set_case_expr, to handle the new continuation destination.
sql/sp_head.h:
New abstract class between sp_instr and instructions with destinations, in particular
sp_instr_set_case_expr, for continuation destination handling.
Changed type of some parameters and variables (sp_instr_opt_meta instead of sp_instr_jump*).
Added opt_mark(), opt_move() and set_destination() methods to
sp_instr_set_case_expr.
sql/sql_parse.cc:
Fixed small bug at show_routine_code() call (tested return value the wrong way).
sql/sql_yacc.yy:
sp_instr_set_case_expr is now added to backpatch list (for the new cont. destination).
Second version.
The problem was that the optimizer didn't work correctly with forwards jumps
to "no-op" hpop and cpop instructions.
Don't generate "no-op" instructions (hpop 0 and cpop 0), it isn't actually
necessary.
mysql-test/r/sp-code.result:
Updated results for new test case (BUG#15737)
mysql-test/t/sp-code.test:
New test case (BUG#15737)
sql/sp_head.cc:
Removed backpatch methods from sp_instr_hpop/cpop, since they're not needed any more.
Added more documentation to sp_head::optimize()
sql/sp_head.h:
Removed backpatch and opt_mark methods from sp_instr_hpop/cpop, since they're not needed
any more.
Added comments to optimizer methods in sp_instr.
sql/sql_yacc.yy:
Don't generate "no-op" hpop and cpop instructions for LEAVE, it's not necessary.
Just generate them when needed.
The bug appears after implementation of WL#2984
(Make stored routine variables work according to the standard).
mysql-test/r/type_varchar.result:
Update result file.
mysql-test/t/type_varchar.test:
Add a test for BUG#15588.
sql/field.cc:
- use memmove() instead of memcpy() -- after implementation of WL#2984
(Make stored routine variables work according to the standard) it is
possible to store in the field the value from this field. For instance,
this can happen for the following statement:
SET sp_var = SUBSTR(sp_var, 1, 3);
sql/sp_head.cc:
- Work correctly with String:
- String length has to be be reset before use;
- qs_append() does not allocate memory, so the memory should
be reserved beforehand.
sql/sql_select.cc:
Polishing: should have been done in WL#2984.
into mysql.com:/extern/mysql/work/bug15658/mysql-5.0
mysql-test/r/sp-error.result:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sp_head.h:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/share/errmsg.txt:
Auto merged
functions".
We should ignore alias when we check if table was already marked as temporary
when we calculate set of tables to be prelocked. Otherwise we will erroneously
treat tables which are used in same routine and have same name but different
alias as non-temporary.
mysql-test/r/sp.result:
Added test for bug #12198 "Temporary table aliasing does not work inside stored
functions" and other tests which cover handling of temporary tables in prelocked
mode.
mysql-test/t/sp.test:
Added test for bug #12198 "Temporary table aliasing does not work inside stored
functions" and other tests which cover handling of temporary tables in prelocked
mode.
sql/sp_head.cc:
sp_head::merge_table_list():
We should ignore alias when we check if table was already marked as temporary
when we calculate set of tables to be prelocked. Otherwise we will erroneously
treat tables which are used in same routine and have same name but different
alias as non-temporary.
Empty strings (and names with trailing spaces) should not be allowed.
mysql-test/r/sp-error.result:
New testcase for BUG#15658
mysql-test/t/sp-error.test:
New testcase for BUG#15658
sql/share/errmsg.txt:
New error message for bad stored routine names.
sql/sp_head.cc:
Added function for checking SP names. (Mustn't be empty or contain trailing spaces.)
sql/sp_head.h:
Added function for checking SP names.
sql/sql_yacc.yy:
Check db and name for stored routines.
There are two main idea of this fix:
- introduce a common function for server and client to split user value
(<user name>@<host name>) into user name and host name parts;
- dump DEFINER clause in correct format in mysqldump.
BitKeeper/etc/ignore:
added client/my_user.c libmysqld/my_user.c sql/my_user.c
client/Makefile.am:
Use my_user.c in linking of mysqldump executable.
client/mysqldump.c:
Fix for BUG#15110(mysqldump --triggers: does not include DEFINER clause)
include/Makefile.am:
Add my_user.c
include/mysql_com.h:
Introduce a constant for max user length.
libmysqld/Makefile.am:
Add my_user.c
mysql-test/r/mysqldump.result:
Update result file.
sql-common/Makefile.am:
Add my_user.c
sql/Makefile.am:
Add my_user.c
sql/sp.cc:
Use constant for max user length.
sql/sp_head.cc:
Use common function to parse user value.
sql/sql_acl.cc:
Use constant for max user length.
sql/sql_parse.cc:
Use constant for max user length.
sql/sql_show.cc:
Use constant for max user length.
sql/sql_trigger.cc:
Use constant for max user length.
include/my_user.h:
A header file for parse_user().
sql-common/my_user.c:
A new file for parse_user() implementation.
into mysql.com:/home/my/mysql-5.0
mysql-test/r/create.result:
Auto merged
mysql-test/r/trigger.result:
Auto merged
mysql-test/r/view.result:
Auto merged
mysql-test/t/create.test:
Auto merged
mysql-test/t/trigger.test:
Auto merged
mysql-test/t/view.test:
Auto merged
sql/field.cc:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/log_event.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/sp.cc:
Auto merged
sql/sp_head.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_select.cc:
Auto merged
mysql-test/t/disabled.def:
Manual merge
sql/mysqld.cc:
Manual merge
sql/sp_head.cc:
Manual merge
sql/sql_trigger.cc:
Manual merge
- Fixed tests
- Optimized new code
- Fixed some unlikely core dumps
- Better bug fixes for:
- #14397 - OPTIMIZE TABLE with an open HANDLER causes a crash
- #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null
mysql-test/r/create.result:
Update results after removing wrong warnings for CREATE ... SELECT
New tests
mysql-test/r/handler.result:
Drop used tables
mysql-test/r/kill.result:
Make test portable
mysql-test/r/mysqlshow.result:
Drop tables used by previous test
mysql-test/r/trigger.result:
Reuse old procedure name
mysql-test/r/view.result:
Extra tests
mysql-test/t/create.test:
New tests to test fix of removing wrong warnings for CREATE ... SELECT
mysql-test/t/disabled.def:
Enable 'kill' test (should now be portable)
mysql-test/t/handler.test:
Drop used tables
mysql-test/t/kill.test:
Make test portable even if kill doesn't work at once
mysql-test/t/mysqlshow.test:
Drop tables used by previous test
mysql-test/t/trigger.test:
Reuse old procedure name
mysql-test/t/view.test:
Extra tests
sql/field.cc:
Removed compiler warning
sql/ha_federated.cc:
my_snprintf -> strmake()
(Simple optimization)
sql/ha_ndbcluster.cc:
Indentation cleanups and trival optimization
sql/item.cc:
Moved save_org_in_field() to item.cc to make it easier to test
Remove setting of null_value as this is not needed
sql/item.h:
Moved save_org_in_field() to item.cc to make it easier to test
sql/log_event.cc:
Remove inline of slave_load_file_stem()
Added 'extension' parameter to slave_load_file_stem() to get smaller code
Removed not critical (or needed) DBUG_ASSERT()'s
Cleaned up usage of slave_load_file_stem() to not depend on constant string lengths
Indentation fixes
sql/opt_range.cc:
Moved code from declaration to function body
(To make it more readable)
sql/parse_file.cc:
Fixed DBUG_PRINT
sql/sp.cc:
Simple cleanups
- Removed not needed {} level
- Ensure saved variables starts with old_
sql/sp_head.cc:
Indentation fixes
Remove core dump when using --debug when m_next_cached_sp == 0
Fixed compiler warnings
Trivial optimizations
sql/sp_head.h:
Changed argument to set_definer() to const
Added THD argument to recursion_level_error() to avoid call to current_thd
sql/sql_acl.cc:
Removed not needed test (first_not_own_table is the guard)
sql/sql_base.cc:
Removed extra empty line
sql/sql_handler.cc:
Don't test table version in mysql_ha_read() as this is already tested in lock_tables()
Moved call to insert_fields to be after lock_table() to guard aganst reopen of tables
(Better fix for Bug#14397 - OPTIMIZE TABLE with an open HANDLER causes a crash)
sql/sql_insert.cc:
Mark fields that are set in CREATE ... SELECT as used
(Removed wrong warnings about field not having a default value)
sql/sql_parse.cc:
Removed not needed test of 'tables' (first_not_own_table is the guard)
Simplify code
sql/sql_select.cc:
Use group->field to check if value is null instead of item called by 'save_org_in_field'
This is a better bug fix for #14850 (ERROR 1062 when a quering a view using a Group By on a column that can be null)
sql/sql_trigger.cc:
Move sql_modes_parameters outside of function
Indentation fixes
Fixed compiler warning
Ensure that thd->lex->query_tables_own_last is set properly before calling check_table_access()
(This allows us to remove the extra test in check_grant() and check_table_access())
into mysql.com:/Users/kent/mysql/bk/mysql-5.0
mysql-test/r/skip_name_resolve.result:
Auto merged
mysql-test/t/skip_name_resolve.test:
Auto merged
sql/sp_head.cc:
Auto merged