should fail to create
The problem was that this type of errors was checked during view
creation, which doesn't happen when CREATE VIEW is a statement of
a created stored routine.
The solution is to perform the checks at parse time. The idea of the
fix is that the parser checks if a construction just parsed is allowed
in current circumstances by testing certain flags, and this flags are
reset for VIEWs.
The side effect of this change is that if the user already have
such bogus routines, it will now get a error when trying to do
SHOW CREATE PROCEDURE proc;
(and some other) and when trying to execute such routine he will get
ERROR 1457 (HY000): Failed to load routine test.p5. The table mysql.proc is missing, corrupt, or contains bad data (internal code -6)
However there should be very few such users (if any), and they may
(and should) drop these bogus routines.
mysql-test/r/sp-error.result:
Add result for bug#20953: create proc with a create view that uses
local vars/params should fail to create.
mysql-test/r/view.result:
Update results.
mysql-test/t/sp-error.test:
Add test case for bug#20953: create proc with a create view that uses
local vars/params should fail to create.
mysql-test/t/view.test:
Add second test for variable in a view.
Remove SP variable in a view test, as it tests wrong behaviour.
Add test for derived table in a view.
sql/sql_lex.cc:
Remove LEX::variables_used.
sql/sql_lex.h:
Remove LEX::variables_used and add st_parsing_options structure and
LEX::parsing_options member.
sql/sql_view.cc:
Move some error checking to sql/sql_yacc.yy.
sql/sql_yacc.yy:
Check for disallowed syntax in a CREATE VIEW at parse time to rise a
error when it is used inside CREATE PROCEDURE and CREATE FUNCTION, as
well as by itself.
into bodhi.local:/opt/local/work/mysql-5.0-runtime
sql/ha_ndbcluster.cc:
Auto merged
sql/item.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/sql_update.cc:
Manual merge.
into mysql.com:/home/tomash/src/mysql_ab/mysql-5.0-bug20570
sql/item_strfunc.cc:
Auto merged
sql/item_strfunc.h:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/view_grant.result:
Manual merge.
mysql-test/t/view_grant.test:
Manual merge.
into mysql.com:/home/gluh/MySQL/Merge/5.0-kt
sql/item.cc:
Auto merged
sql/item.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
sql/table.cc:
Auto merged
tests/mysql_client_test.c:
Auto merged
invoker name
The bug was fixed similar to how context switch is handled in
Item_func_sp::execute_impl(): we store pointer to current
Name_resolution_context in Item_func_current_user class, and use
its Security_context in Item_func_current_user::fix_fields().
mysql-test/r/view_grant.result:
Add result for bug#20570.
mysql-test/t/view_grant.test:
Add test case for bug#20570.
sql/item_create.cc:
Remove create_func_current_user(), as it is not used for automatic
function creation.
sql/item_create.h:
Remove prototype for create_func_current_user().
sql/item_strfunc.cc:
Add implementations for Item_func_user::init(),
Item_func_user::fix_fields() and
Item_func_current_user::fix_fields() methods. The latter uses
Security_context from current Name_resolution_context, if one is
defined.
sql/item_strfunc.h:
Move implementation of CURRENT_USER() out of Item_func_user to
to new Item_func_current_user class. For both classes calculate
user name in fix_fields() method.
For Item_func_current_user add context field to store
Name_resolution_context in effect.
sql/sql_yacc.yy:
Pass current Name_resolution_context to Item_func_current_user.
Table comment: issue a warning(error in traditional mode) if length of comment > 60 symbols
Column comment: issue a warning(error in traditional mode) if length of comment > 255 symbols
Table 'comment' is changed from char* to LEX_STRING
mysql-test/r/strict.result:
test case
mysql-test/t/strict.test:
test case
sql/handler.h:
Table 'comment' is changed from char* to LEX_STRING
sql/sql_show.cc:
Table 'comment' is changed from char* to LEX_STRING
sql/sql_table.cc:
Table 'comment' is changed from char* to LEX_STRING
sql/sql_yacc.yy:
Table 'comment' is changed from char* to LEX_STRING
sql/table.cc:
Table 'comment' is changed from char* to LEX_STRING
sql/table.h:
Table 'comment' is changed from char* to LEX_STRING
sql/unireg.cc:
Fix for bug#13934 Silent truncation of table comments
Table comment: issue a warning(error in traditional mode) if length of comment > 60 symbols
Column comment: issue a warning(error in traditional mode) if length of comment > 255 symbols
user name is calculated on function execution stage instead of parse stage
mysql-test/r/sp_notembedded.result:
Bug#15298 SHOW GRANTS FOR CURRENT_USER: Incorrect output in DEFINER context
test case
mysql-test/t/sp_notembedded.test:
Bug#15298 SHOW GRANTS FOR CURRENT_USER: Incorrect output in DEFINER context
test case
sql/mysql_priv.h:
Bug#15298 SHOW GRANTS FOR CURRENT_USER: Incorrect output in DEFINER context
new get_current_user(THD *thd, LEX_USER *user) function
sql/sql_acl.cc:
Bug#15298 SHOW GRANTS FOR CURRENT_USER: Incorrect output in DEFINER context
user name is calculated using get_current_user() function
sql/sql_parse.cc:
Bug#15298 SHOW GRANTS FOR CURRENT_USER: Incorrect output in DEFINER context
new get_current_user() function
user name is calculated using get_current_user() function
sql/sql_yacc.yy:
Bug#15298 SHOW GRANTS FOR CURRENT_USER: Incorrect output in DEFINER context
empty LEX_USER struct for CURRENT USER,
user name is calculated on function execution stage
The problem was that we restored SQL_CACHE, SQL_NO_CACHE flags in SELECT
statement from internal structures based on value set later at runtime, not
the original value set by the user.
The solution is to remember that original value.
mysql-test/r/auto_increment.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/func_compress.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/func_math.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/func_system.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/func_time.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/information_schema.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/query_cache.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/rpl_get_lock.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/rpl_master_pos_wait.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/show_check.result:
Add result for bug#17203.
mysql-test/r/subselect.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/type_blob.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/variables.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/r/view.result:
Update result to not report SQL_NO_CACHE if it wasn't there at first place.
mysql-test/t/show_check.test:
Add test case for bug#17203.
sql/sql_lex.cc:
Reset SELECT_LEX::sql_cache together with SELECT_LEX::options.
sql/sql_lex.h:
Add SELECT_LEX::sql_cache field to store original user setting.
sql/sql_select.cc:
Output SQL_CACHE and SQL_NO_CACHE depending on stored original user setting.
sql/sql_yacc.yy:
Make effect of SQL_CACHE and SQL_NO_CACHE mutually exclusive. Ignore
SQL_CACHE if SQL_NO_CACHE was used. Remember what was set by the user.
Reset SELECT_LEX::sql_cache together with SELECT_LEX::options.
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.
resulted in a wrong error message.
The nest_level counter indicates the depth of nesting for a subselect. It is
needed to properly resolve aggregate functions in nested subselects. Obviously
it shouldn't be incremented for UNION parts because they have the same level of
nesting. This counter was incremented by 1 in the mysql_new_select() function
for any new select and wasn't decremented for UNION parts. This resulted in
wrongly reported error messages.
Now the nest_level counter is decremented by 1 for any union part.
mysql-test/t/union.test:
Added test case for the bug#18175: The nest_level counter wasn't decremented for union parts which
resulted in a wrong error message.
mysql-test/r/union.result:
Added test case for the bug#18175: The nest_level counter wasn't decremented for union parts which
resulted in a wrong error message.
sql/sql_yacc.yy:
Fixed bug#18175: The nest_level counter wasn't decremented for union parts which
resulted in a wrong error message.
Now the nest_level counter is decremented by 1 for any union part.
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
over two views when using syntax with curly braces.
Each outer join operation must be placed in a separate
nest. This was not done when the syntax with curly braces
was used. In some cases, in particular, for queries with outer
join operation over views it could cause a crash.
mysql-test/r/join_outer.result:
Added a test case for bug #19396.
mysql-test/t/join_outer.test:
Added a test case for bug #19396.
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).
There were two distict bugs: parse error was returned for valid
statement and that error wasn't reported to the client.
The fix ensures that EXPLAIN SELECT..INTO is accepted by parser and any
other parse error will be reported to the client.
mysql-test/r/explain.result:
Add result for bug#15463.
mysql-test/t/explain.test:
Add test case for bug#15463.
sql/sql_parse.cc:
Assert that if parsing error has occured then apropriate error message
has been pushed into error stack.
sql/sql_yacc.yy:
If there is no lex->result in select_var_ident rule, then we have
to be in DESCRIBE mode.
The bug caused wrong result sets for union constructs of the form
(SELECT ... ORDER BY order_list1 [LIMIT n]) ORDER BY order_list2.
For such queries order lists were concatenated and limit clause was
completely neglected.
mysql-test/r/order_by.result:
Added a test case for bug #18767.
mysql-test/t/order_by.test:
Added a test case for bug #18767.
sql/sql_lex.h:
Fixed bug #18767.
Placed the code the created a fake SELECT_LEX into a separate function.
sql/sql_parse.cc:
Fixed bug #18767.
Placed the code the created a fake SELECT_LEX into a separate function.
sql/sql_select.cc:
Fixed bug #18767.
Changed the condition on which a SELECT is treated as part of a UNION.
The SELECT in
(SELECT ... ORDER BY order_list1 [LIMIT n]) ORDER BY order_list2
now is handled in the same way as the first SELECT in a UNION
sequence.
sql/sql_union.cc:
Fixed bug #18767.
Changed the condition at which a SELECT is treated as part of a UNION.
The SELECT in
(SELECT ... ORDER BY order_list1 [LIMIT n]) ORDER BY order_list2
now is handled in the same way as the first SELECT in a UNION
sequence.
sql/sql_yacc.yy:
Fixed bug #18767.
Changed the condition at which a SELECT is treated as part of a UNION.
The SELECT in
(SELECT ... ORDER BY order_list1 [LIMIT n]) ORDER BY order_list2
now is handled in the same way as the first SELECT in a UNION
sequence. In the same way is handled the SELECT in
(SELECT ... LIMIT n) ORDER BY order list.
Yet if there is neither ORDER BY nor LIMIT in the single-select
union construct
(SELECT ...) ORDER BY order_list
then it is still handled as simple select with an order clause.
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.
Fixed in parser. rpl_view gained no changes but rpl_view-slave.opt.
sql/sql_yacc.yy:
UPDATING option for create/alter view is added for tables_ok to finds the view's
TABLE_LIST.updating as true. FIXME: Regarding to UPDATING option `create view' should not have
any difference from `create table'.
mysql-test/t/rpl_view-slave.opt:
The option is needed to force slave executes tables_ok which must return OK in conditions of this tests (no table foo is used.
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.
because it can couse problem with Query cache (BUG#14767)
mysql-test/r/query_cache_notembedded.result:
BUG#14767 test suite.
mysql-test/t/query_cache_notembedded.test:
BUG#14767 test suite.
sql/sql_insert.cc:
Query cache invalidation table we was inserting in just after
unlocking table added to avoid the race condition as we had
with SP.
sql/sql_parse.cc:
Query cache invalidation table we was inserting in just after
unlocking table added to avoid the race condition as we had
with SP.
sql/sql_yacc.yy:
We should prohibit concurent read of unserting file in SP
because it can cause problem with query cache.
After the ChangeSet 1.1892.20.1 2005/08/24 (Bug #12562) SYSDATE() is not an alias
of NOW() and is unsafe for replication.
`SYSDATE()' backward compatible aliasing clashes with the idea #12562
fix. To make it safe-replicatable we have to either use RBR or to restore
the pre-5.0 style.
--sysdate-is-now command line flag was introduced to provide backward compatibility.
sql/mysqld.cc:
New option to force SYSDATE's backward compatible with 4.1 aliasing to NOW (not default)
sql/sql_class.h:
new slot to fill at init time and check at parse
sql/sql_yacc.yy:
calling NOW's branches when --sysdate-is-now
mysql-test/r/sysdate_is_now.result:
New BitKeeper file ``mysql-test/r/sysdate_is_now.result''
mysql-test/t/sysdate_is_now-master.opt:
New BitKeeper file ``mysql-test/t/sysdate_is_now-master.opt''
mysql-test/t/sysdate_is_now.test:
New BitKeeper file ``mysql-test/t/sysdate_is_now.test''
into mysql.com:/home/alik/Documents/AllProgs/MySQL/devel/5.0-rt
mysql-test/r/sp.result:
Auto merged
sql/sql_trigger.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/skip_grants.result:
Merge 5.0 and 5.0-runtime.
mysql-test/t/skip_grants.test:
Merge 5.0 and 5.0-runtime.
qualified subject table" which was introduced during work on bug #13525
"Rename table does not keep info of triggers".
The bug was caused by the fact that during reconstruction of CREATE TRIGGER
statement stored in .TRG file which happened during RENAME TABLE we damaged
trigger definition in case when it contained fully qualified name of subject
table (see comment for sql_yacc.yy for more info).
mysql-test/r/trigger.result:
Added test for bug #17866 "Problem with renaming table with triggers with fully
qualified subject table".
mysql-test/t/trigger.test:
Added test for bug #17866 "Problem with renaming table with triggers with fully
qualified subject table".
sql/sql_trigger.cc:
Table_triggers_list::change_table_name_in_triggers():
Instead of trying to use pointer to the end of subject table identifier
we use pointer to the beginning of FOR lexeme now, so during reconstruction
of CREATE TRIGGER statement in this function we need to add extra space
before part which begins with FOR to get nice trigger definition.
sql/sql_yacc.yy:
trigger_tail:
In this rule we can't rely on using remember_end token after table_ident token,
since value returned depends on whether table name is fully qualified or not.
So instead of trying to get pointer to the end of table identifier we use
pointer to the beginning of FOR lexeme.
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.
The idea of the fix is to extend support of non-SUID triggers for backward
compatibility. Formerly non-SUID triggers were appeared when "new" server
is being started against "old" database. Now, they are also created when
"new" slave receives updates from "old" master.
mysql-test/r/rpl_trigger.result:
Updated the result file with the results of the test for BUG#16266.
mysql-test/t/rpl_trigger.test:
Added the test case for BUG#16266.
sql/mysql_priv.h:
Added an utility operation to be used from sql_yacc.yy.
sql/sql_parse.cc:
Add a utility operation to be used from sql_yacc.yy.
sql/sql_trigger.cc:
Extend support of non-SUID triggers.
sql/sql_view.cc:
Initialize LEX::definer if DEFINER-clause is missing.
sql/sql_yacc.yy:
Extended support of non-SUID triggers.
mysql-test/std_data/bug16266.000001:
A new binlog file for testing a patch for BUG#16266.
into mysql.com:/home/dlenev/src/mysql-5.0-bg13525
sql/sql_table.cc:
Auto merged
sql/sql_trigger.cc:
Auto merged
sql/sql_trigger.h:
Auto merged
sql/sql_yacc.yy:
Auto merged
mysql-test/r/trigger.result:
SCCS merged
mysql-test/t/trigger.test:
SCCS merged
Let us transfer triggers associated with table when we rename it (but only if
we are not changing database to which table belongs, in the latter case we will
emit error).
mysql-test/r/trigger.result:
Added test for bug #13525 "Rename table does not keep info of triggers".
mysql-test/t/trigger.test:
Added test for bug #13525 "Rename table does not keep info of triggers".
sql/sql_rename.cc:
rename_tables():
Now after renaming table's .FRM file and updating handler data we call
Table_triggers_list::change_table_name() which is reponsible for
updating .TRG and .TRN files.
sql/sql_table.cc:
mysql_alter_table():
Now in case when ALTER should rename table we call
Table_triggers_list::change_table_name() which is responsible
for updating .TRG and .TRN files after renaming table.
sql/sql_trigger.cc:
Added Table_triggers_list::change_table_name() method and
change_table_name_in_triggers()/trignames() methods responsible for updating
.TRG and .TRN files for table during its renaming.
Two small cleanups - removed versioning for .TRG files (since it was not working
before anyway) and emphasized that type of lock specified in tables list is
unimportant for DROP TABLE (since this statement uses name-locking).
sql/sql_trigger.h:
Table_triggers_list:
Added on_table_names_list member to store pointers and lenghts of
"ON table_name" parts in triggers' definitions to be able easily
change them during RENAME TABLE.
Added change_table_name() method and change_table_name_in_trignames/triggers()
helper methods responsible for updating .TRG and .TRN files.
sql/sql_yacc.yy:
trigger_tail:
To be able properly update triggers' definitions with new table names
when renaming tables we need to know where in CREATE TRIGGER statement
"ON db_name.table_name" part resides.
Small cleanup - let us emphasize that for CREATE TRIGGER statement
lock type which is specified in table list is unimportant since
name-locking is used.
necessary implementation in the server
mysql_upgrade script added
client/mysqlcheck.c:
--check-upgrade option added
include/my_base.h:
errcode added
include/myisam.h:
option added
scripts/Makefile.am:
mysql_upgrade script added
sql/handler.cc:
checks for old types/bugs added
sql/handler.h:
declarations regarding checks for upgrade
sql/lex.h:
sym added
sql/share/errmsg.txt:
error message added
sql/slave.cc:
now ha_repair is for public use
sql/sql_table.cc:
upgrade in ha_repair implemented
sql/sql_yacc.yy:
CHECK ... FOR UPGRADE added to syntax
The problem was a code generation bug: cpop instructions were not generated
when using ITERATE back to an outer block from a context with a declared
cursor; this would make it push a new cursor without popping in-between,
eventually overrunning the cursor stack with a crash as the result.
Fixed the calculation of how many cursors to pop (in sp_pcontext.cc:
diff_cursors()), and also corrected diff_cursors() and diff_handlers()
to when doing a "leave"; don't include the last context we're leaving
(we are then jumping to the appropriate pop instructions).
mysql-test/r/sp.result:
Updated result for new test case (BUG#16887)
mysql-test/t/sp.test:
New test case for BUG#16887
sql/sp_pcontext.cc:
Added new parameter to sp_pcontext::diff_handlers() and diff_cursors():
They can either include (for iterate jumps) or exclude (for leave jumps)
the outer context.
Fixed bug in diff_cursors(); it was just plain wrong and would return
zero in some situations when it shouldn't.
sql/sp_pcontext.h:
Added new parameter to sp_pcontext::diff_handlers() and diff_cursors():
They can either include (for iterate jumps) or exclude (for leave jumps)
the outer context.
sql/sql_yacc.yy:
Added parameter to diff_handlers/diff_cursors depending on if it's an
iterate or leave jump.
For "leave", we don't have to include the last context we're leaving since
we will jump to the appropriate pop instructions.
Backporting character_set_filesystem from 5.0 to 5.1.
sql/mysqld.cc:
Backporting character_set_filesystem from 5.0 to 5.1.
sql/set_var.cc:
Backporting character_set_filesystem from 5.0 to 5.1.
sql/set_var.h:
Backporting character_set_filesystem from 5.0 to 5.1.
sql/sql_class.cc:
Backporting character_set_filesystem from 5.0 to 5.1.
sql/sql_class.h:
Backporting character_set_filesystem from 5.0 to 5.1.
sql/sql_yacc.yy:
Backporting character_set_filesystem from 5.0 to 5.1.
mysql-test/t/variables.test:
Backporting character_set_filesystem from 5.0 to 5.1.
mysql-test/r/variables.result:
Backporting character_set_filesystem from 5.0 to 5.1.
Check if AGGREGATE was given with a stored (non-UDF) function, and return
error in that case.
Also made udf_example/udf_test work again, by adding a missing *_init()
function. (_init() functions required unless --allow_suspicious_udfs is
given to the server, since March 2005 - it seems udf_example wasn't updated
at the time.)
mysql-test/r/sp-error.result:
Updated results for BUG#16896.
mysql-test/t/sp-error.test:
Added test case for BUG#16896.
sql/share/errmsg.txt:
New error message: ER_SP_NO_AGGREGATE
sql/sql_yacc.yy:
Check if AGGREGATE was used when creating a stored function (i.e. not an UDF).
sql/udf_example.cc:
Added myfunc_int_init() function to make it work when the server is running without
--allow_suspicious_udfs.
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
We should disallow usage of RETURN statement in triggers and emit
error at parsing time (instead of crashing when trigger is fired).
mysql-test/r/trigger.result:
Added test for bug #16829 "Firing trigger with RETURN crashes the server".
mysql-test/t/trigger.test:
Added test for bug #16829 "Firing trigger with RETURN crashes the server".
sql/sql_yacc.yy:
We should disallow usage of RETURN statement in triggers and emit
error at parsing time (instead of crashing when trigger is fired).
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.
- BUG#15166: Wrong update permissions required to execute triggers
- BUG#15196: Wrong select permission required to execute triggers
The idea of the fix is to check necessary privileges
in Item_trigger_field::fix_fields(), instead of having "special variables"
technique. To achieve this, we should pass to an Item_trigger_field instance
a flag, which will indicate the usage/access type of this trigger variable.
mysql-test/r/trigger-grant.result:
Update the result file.
mysql-test/t/trigger-grant.test:
Add test cases for BUG#15166 and BUG#15196
sql/item.cc:
Item_trigger_field: check appropriate (SELECT/UPDATE) privilege in fix_fields().
sql/item.h:
Add a flag to specify access type for trigger field.
sql/sql_trigger.cc:
"Special variable" technique of checking privileges for NEW/OLD variables
was replaced by checking table- and column-level privileges in
Item_trigger_field::fix_fields().
sql/sql_trigger.h:
"Special variable" technique of checking privileges for NEW/OLD variables
was replaced by checking table- and column-level privileges in
Item_trigger_field::fix_fields().
sql/sql_yacc.yy:
Specify access type for trigger fields.
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
into moonbone.local:/work/15538-bug-5.0-mysql
mysql-test/r/select.result:
Auto merged
mysql-test/t/select.test:
Auto merged
sql/sql_yacc.yy:
Auto merged