Commit graph

43384 commits

Author SHA1 Message Date
unknown
71f90b7e6f Manual merge 2007-03-06 13:46:33 -07:00
unknown
0708859ba8 Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-8407_b
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-8407-merge


mysql-test/r/information_schema_db.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/lock.cc:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sp_head.h:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_update.cc:
  Auto merged
sql/table.cc:
  Auto merged
sql/table.h:
  Auto merged
2007-03-06 10:33:10 -07:00
unknown
c155c66da6 Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new-rpl
into  bodhi.local:/opt/local/work/mysql-5.1-runtime-merge


mysql-test/t/disabled.def:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sp_head.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_parse.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.h:
  Auto merged
mysql-test/r/show_check.result:
  Manual merge.
mysql-test/t/show_check.test:
  Manual merge.
2007-03-06 16:44:14 +03:00
unknown
266a7fff52 Bug#8407 (Stored functions/triggers ignore exception handler)
Bug 18914 (Calling certain SPs from triggers fail)
Bug 20713 (Functions will not not continue for SQLSTATE VALUE '42S02')
Bug 21825 (Incorrect message error deleting records in a table with a
  trigger for inserting)
Bug 22580 (DROP TABLE in nested stored procedure causes strange dependency
  error)
Bug 25345 (Cursors from Functions)


This fix resolves a long standing issue originally reported with bug 8407,
which affect the behavior of Stored Procedures, Stored Functions and Trigger
in many different ways, causing symptoms reported by all the bugs listed.
In all cases, the root cause of the problem traces back to 8407 and how the
server locks tables involved with sub statements.

Prior to this fix, the implementation of stored routines would:
- compute the transitive closure of all the tables referenced by a top level
statement
- open and lock all the tables involved
- execute the top level statement
"transitive closure of tables" means collecting:
- all the tables,
- all the stored functions,
- all the views,
- all the table triggers
- all the stored procedures
involved, and recursively inspect these objects definition to find more
references to more objects, until the list of every object referenced does
not grow any more.
This mechanism is known as "pre-locking" tables before execution.
The motivation for locking all the tables (possibly) used at once is to
prevent dead locks.

One problem with this approach is that, if the execution path the code
really takes during runtime does not use a given table, and if the table is
missing, the server would not execute the statement.
This in particular has a major impact on triggers, since a missing table
referenced by an update/delete trigger would prevent an insert trigger to run.

Another problem is that stored routines might define SQL exception handlers
to deal with missing tables, but the server implementation would never give
user code a chance to execute this logic, since the routine is never
executed when a missing table cause the pre-locking code to fail.

With this fix, the internal implementation of the pre-locking code has been
relaxed of some constraints, so that failure to open a table does not
necessarily prevent execution of a stored routine.

In particular, the pre-locking mechanism is now behaving as follows:

1) the first step, to compute the transitive closure of all the tables
possibly referenced by a statement, is unchanged.

2) the next step, which is to open all the tables involved, only attempts
to open the tables added by the pre-locking code, but silently fails without
reporting any error or invoking any exception handler is the table is not
present. This is achieved by trapping internal errors with
Prelock_error_handler

3) the locking step only locks tables that were successfully opened.

4) when executing sub statements, the list of tables used by each statements
is evaluated as before. The tables needed by the sub statement are expected
to be already opened and locked. Statement referencing tables that were not
opened in step 2) will fail to find the table in the open list, and only at
this point will execution of the user code fail.

5) when a runtime exception is raised at 4), the instruction continuation
destination (the next instruction to execute in case of SQL continue
handlers) is evaluated.
This is achieved with sp_instr::exec_open_and_lock_tables()

6) if a user exception handler is present in the stored routine, that
handler is invoked as usual, so that ER_NO_SUCH_TABLE exceptions can be
trapped by stored routines. If no handler exists, then the runtime execution
will fail as expected.

With all these changes, a side effect is that view security is impacted, in
two different ways.

First, a view defined as "select stored_function()", where the stored
function references a table that may not exist, is considered valid.
The rationale is that, because the stored function might trap exceptions
during execution and still return a valid result, there is no way to decide
when the view is created if a missing table really cause the view to be invalid.

Secondly, testing for existence of tables is now done later during
execution. View security, which consist of trapping errors and return a
generic ER_VIEW_INVALID (to prevent disclosing information) was only
implemented at very specific phases covering *opening* tables, but not
covering the runtime execution. Because of this existing limitation,
errors that were previously trapped and converted into ER_VIEW_INVALID are
not trapped, causing table names to be reported to the user.
This change is exposing an existing problem, which is independent and will
be resolved separately.


mysql-test/r/information_schema_db.result:
  Revised the pre-locking code implementation, aligned the tests.
mysql-test/r/sp-error.result:
  Revised the pre-locking code implementation, aligned the tests.
mysql-test/r/sp.result:
  Revised the pre-locking code implementation, aligned the tests.
mysql-test/r/trigger.result:
  Revised the pre-locking code implementation, aligned the tests.
mysql-test/r/view.result:
  Revised the pre-locking code implementation, aligned the tests.
mysql-test/t/sp-error.test:
  Revised the pre-locking code implementation, aligned the tests.
mysql-test/t/sp.test:
  Revised the pre-locking code implementation, aligned the tests.
mysql-test/t/trigger.test:
  Revised the pre-locking code implementation, aligned the tests.
sql/lock.cc:
  table->placeholder now checks for schema_table
sql/mysqld.cc:
  my_message_sql(): invoke internal exception handlers
sql/sp_head.cc:
  exec_open_and_lock_tables(): open and lock tables, or return the
  continuation destination of this instruction
sql/sp_head.h:
  exec_open_and_lock_tables(): open and lock tables, or return the
  continuation destination of this instruction
sql/sql_base.cc:
  Prelock_error_handler: delay open table errors until execution
sql/sql_class.cc:
  THD: add internal error handler, as an exception mechanism.
sql/sql_class.h:
  THD: add internal error handler, as an exception mechanism.
sql/sql_update.cc:
  table->placeholder now checks for schema_table
sql/table.cc:
  st_table_list::hide_view_error(): masked more errors for view security
sql/table.h:
  table->placeholder now checks for schema_table, and unopened tables
2007-03-05 19:42:07 -07:00
unknown
4268313e50 Removing global events_till_disconnect variable as it is replaced by a member of
master info structure.
2007-03-02 10:35:04 +01:00
unknown
198a8abd87 Merge BUG: Windows target won't compile.
- winsock2.h must be included before windows.h
2007-03-02 09:04:23 +01:00
unknown
7be25714a7 Manual merge 2007-03-01 20:04:49 -07:00
unknown
93e6eb8037 Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-26093
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-26093-merge


mysql-test/r/func_misc.result:
  Auto merged
2007-03-01 19:22:43 -07:00
unknown
0a93be2869 Bug#26093 (SELECT BENCHMARK() for SELECT statements does not produce valid
results)

Before this fix, the function BENCHMARK() would fail to evaluate expressions
like "(select avg(a) from t1)" in debug builds (with an assert),
or would report a time of zero in non debug builds.

The root cause is that evaluation of DECIMAL_RESULT expressions was not
supported in Item_func_benchmark::val_int().

This has been fixed by this change.


mysql-test/r/func_misc.result:
  Added support for DECIMAL_RESULT in Item_func_benchmark::val_int()
mysql-test/t/func_misc.test:
  Added support for DECIMAL_RESULT in Item_func_benchmark::val_int()
sql/item_func.cc:
  Added support for DECIMAL_RESULT in Item_func_benchmark::val_int()
2007-03-01 19:20:47 -07:00
unknown
bf4996c4eb Missing parameter to DBUG_PRINT 2007-03-01 18:14:51 -07:00
unknown
2e34602392 Fixed compiler warnings
server-tools/instance-manager/angel.cc:
  Compiler warnings
sql/event_queue.cc:
  Compier warnings
sql/event_scheduler.cc:
  Compiler warnings
sql/events.cc:
  Compiler warnings
2007-03-01 16:39:00 -07:00
unknown
38a8283c6d Manual merge of 5.1 into 5.1-runtime
mysql-test/r/subselect.result:
  Manual merge
server-tools/instance-manager/mysqlmanager.cc:
  Manual merge
sql/event_scheduler.cc:
  Manual merge
sql/sql_parse.cc:
  Manual merge
2007-03-01 13:47:28 -07:00
unknown
0b0abf2b66 Merge rsomla@bk-internal.mysql.com:/home/bk/mysql-5.1-new-rpl
into  quant.(none):/ext/mysql/bkroot/mysql-5.1-new-rpl


sql/slave.cc:
  Auto merged
2007-03-01 16:32:57 +01:00
unknown
17b3cbe81b Post-merge fix 2007-03-01 16:17:48 +01:00
unknown
e95a62a737 Merge mysql.com:/nfsdisk1/lars/bk/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/bk/mysql-5.1-new-rpl


mysql-test/r/mysqlbinlog.result:
  Auto merged
mysql-test/r/rpl_replicate_do.result:
  Auto merged
mysql-test/t/mysqlbinlog.test:
  Auto merged
mysql-test/t/rpl_replicate_do.test:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
sql/sql_trigger.cc:
  Auto merged
sql/sql_trigger.h:
  Auto merged
sql/slave.cc:
  Manual merge
sql/sql_insert.cc:
  Manual merge
sql/sql_parse.cc:
  Manual merge
sql/sql_yacc.yy:
  Manual merge
2007-03-01 15:39:57 +01:00
unknown
683c1e6ad7 After merge fix
mysql-test/t/rpl_loaddata_simple.test:
  Rename: mysql-test/t/rpl_loaddata2.test -> mysql-test/t/rpl_loaddata_simple.test
mysql-test/r/rpl_loaddata_simple.result:
  Rename: mysql-test/r/rpl_loaddata2.result -> mysql-test/r/rpl_loaddata_simple.result
2007-03-01 18:16:17 +04:00
unknown
b9959b748a after merge fix 2007-03-01 16:08:13 +04:00
unknown
783634d6d4 Merge mysql.com:/home/bar/mysql-5.0.merge
into  mysql.com:/home/bar/mysql-5.1-rpl


mysql-test/r/mysqlbinlog.result:
  Auto merged
mysql-test/t/mysqlbinlog.test:
  Auto merged
sql/log_event.cc:
  Auto merged
sql/log_event.h:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_load.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-03-01 16:06:29 +04:00
unknown
db30ee2642 Merge mysql.com:/home/bar/mysql-5.0.rafal
into  mysql.com:/home/bar/mysql-5.1-rpl


mysql-test/valgrind.supp:
  Null merge of Rafal's change - fix problem was previously fixed in 5.1
2007-03-01 15:14:49 +04:00
unknown
bf9521d24b Fixing manual merge error.
sql/slave.cc:
  Removing piece of code which get there when manual merging from 5.0 tree.
2007-03-01 11:52:20 +01:00
unknown
92e7cf1559 Merge quant.(none):/ext/mysql/bk/mysql-5.0-rpl-warnings
into  quant.(none):/ext/mysql/bkroot/mysql-5.0-rpl
2007-03-01 10:58:13 +01:00
unknown
8fa0d1b98e Removing two more compilation warnings.
sql/slave.cc:
  Guard declaration of variable to avoid "unused variable" warning.
sql/sql_repl.cc:
  Guard declaration of variable to avoid "unused variable" warning.
2007-03-01 10:40:48 +01:00
unknown
b3c7224c3b Merge quant.(none):/ext/mysql/bk/mysql-5.0-bug25306
into  quant.(none):/ext/mysql/bkroot/mysql-5.1-new-rpl


sql/sql_repl.cc:
  Auto merged
sql/slave.cc:
  Manual merge of patch for BUG#25306 from 5.0-rpl tree
2007-03-01 10:03:42 +01:00
unknown
30ece9b060 Fix for wrong replace command. 2007-03-01 12:26:07 +04:00
unknown
16e9e7ed4b Merge quant.(none):/ext/mysql/bk/mysql-5.0-bug25463
into  quant.(none):/ext/mysql/bkroot/mysql-5.0-rpl
2007-03-01 09:23:26 +01:00
unknown
6632872bbe Merge quant.(none):/ext/mysql/bk/mysql-5.0-rpl-warnings
into  quant.(none):/ext/mysql/bkroot/mysql-5.0-rpl
2007-03-01 09:21:32 +01:00
unknown
ef02cb6305 Renaming recenly added test case, because of name conflict
when merging into 5.1.


mysql-test/t/rpl_loaddata_charset.test:
  Rename: mysql-test/t/rpl_loaddata2.test -> mysql-test/t/rpl_loaddata_charset.test
mysql-test/r/rpl_loaddata_charset.result:
  Rename: mysql-test/r/rpl_loaddata2.result -> mysql-test/r/rpl_loaddata_charset.result
2007-03-01 11:52:25 +04:00
unknown
fdb1170eb1 Merge quant.(none):/ext/mysql/bkroot/mysql-5.0-rpl
into  quant.(none):/ext/mysql/bk/mysql-5.0-rpl-warnings


sql/mysql_priv.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-03-01 08:47:49 +01:00
unknown
b3fafa40fc Fixes of compilation warnings and errors.
sql/mysql_priv.h:
  Removing compiler warning "NULL used in arithmetic"
sql/mysqld.cc:
  First argument to WARN_DEPRECATED is supposed to be a pointer (to THD structure)
sql/sql_insert.cc:
  Removing compiler warning "unused variable". Apparently query is not used when compiling libmysqld.
sql/sql_yacc.yy:
  Removing compiler error "Macro already defined"
2007-03-01 08:41:13 +01:00
unknown
d93c7f39f8 Additional fix for bug N 15126
Replacing local directory.


mysql-test/r/mysqlbinlog.result:
  Additional fix for bug N 15126
mysql-test/t/mysqlbinlog.test:
  Additional fix for bug N 15126
2007-03-01 11:23:12 +04:00
unknown
ee950898e3 Merge weblab.(none):/home/marcsql/TREE/mysql-5.1-base
into  weblab.(none):/home/marcsql/TREE/mysql-5.1-rt-merge


include/my_pthread.h:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/r/partition_innodb.result:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
server-tools/instance-manager/IMService.cpp:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/ha_ndbcluster_binlog.cc:
  Auto merged
sql/ha_partition.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/item_subselect.cc:
  Auto merged
sql/item_subselect.h:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/mysqld.cc:
  Auto merged
sql/set_var.cc:
  Auto merged
sql/sql_base.cc:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_lex.cc:
  Auto merged
sql/sql_lex.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
sql/table.cc:
  Auto merged
2007-02-28 18:14:56 -07:00
unknown
58e93b1f9f Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.1-new-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.1-merge


sql/field.cc:
  Auto merged
sql/log.cc:
  Auto merged
sql/mysql_priv.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
2007-02-28 22:32:44 +01:00
unknown
d5e983aafc Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge


sql/mysql_priv.h:
  Auto merged
sql/sql_insert.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
2007-02-28 22:30:40 +01:00
unknown
5c58738ad1 Remove dead code: flush_version was never increased in the server,
therefore the logic associated with it never worked.


sql/ha_partition.cc:
  Remove dead code. Update comments.
sql/mysql_priv.h:
  Remove dead code (flush_version).
sql/mysqld.cc:
  Remove dead code (flush_version).
sql/sql_base.cc:
  Remove dead code.
sql/table.cc:
  Remove dead code.
sql/table.h:
  Remove dead code.
2007-03-01 00:25:50 +03:00
unknown
a2b4f52912 Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl
into  mysql.com:/home/bar/mysql-5.0.b24478
2007-02-28 18:21:00 +04:00
unknown
4a83cd38ea Additional test changes for
Bug N 15126 character_set_database is not replicated (LOAD DATA INFILE need it)
Positions of some binlog events were changed because of
additional logging of @@collation_database.
2007-02-28 18:13:23 +04:00
unknown
18f1d1a200 After merge fix 2007-02-28 17:32:18 +04:00
unknown
de61d5b0d5 Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0-rpl
into  mysql.com:/home/bar/mysql-5.0.b15126


sql/log_event.cc:
  Auto merged
sql/log_event.h:
  Auto merged
sql/sql_class.cc:
  Auto merged
sql/sql_class.h:
  Auto merged
sql/sql_load.cc:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
mysql-test/r/mysqlbinlog.result:
  After merge fix
mysql-test/t/mysqlbinlog.test:
  After merge fix
2007-02-28 17:17:06 +04:00
unknown
c3a3aff54f Bug#15126 character_set_database is not replicated (LOAD DATA INFILE need it)
This patch fixes problem that LOAD DATA could use different
character sets when loading files on master and on slave sides:
- Adding replication of thd->variables.collation_database
- Adding optional character set clause into LOAD DATA

Note, the second way, with explicit CHARACTER SET clause
should be the recommended way to load data using an alternative
character set.
The old way, using "SET @@character_set_database=xxx" should be
gradually depricated.


mysql-test/r/mysqlbinlog.result:
  Adding test case
mysql-test/t/mysqlbinlog.test:
  Adding test case
sql/log_event.cc:
  Adding logging of thd->variables.collation_database
sql/log_event.h:
  Adding declarations
sql/sql_class.cc:
  Exchange character set is null by default
sql/sql_class.h:
  Adding character set into sql_exchange
sql/sql_load.cc:
  - Using exchange character set (if it was specified in LOAD DATA syntax)
  - Using thd->variables.collation_database by default
sql/sql_yacc.yy:
  Adding optional character set clause into LOAD DATA syntax
mysql-test/r/rpl_loaddata2.result:
  New BitKeeper file ``mysql-test/r/rpl_loaddata2.result''
mysql-test/std_data/loaddata6.dat:
  New BitKeeper file ``mysql-test/std_data/loaddata6.dat''
mysql-test/t/rpl_loaddata2.test:
  New BitKeeper file ``mysql-test/t/rpl_loaddata2.test''
2007-02-28 17:06:57 +04:00
unknown
793a137ddd added initialization of 'cmp_type' variable(to remove compiler warning) 2007-02-28 15:44:57 +04:00
unknown
53c5511a9b Merge mysql.com:/home/gluh/MySQL/Merge/5.1
into  mysql.com:/home/gluh/MySQL/Merge/5.1-opt
2007-02-28 13:26:20 +04:00
unknown
8010d9872d valgrind error fix 2007-02-28 13:25:49 +04:00
unknown
9c8637dc4c Merge quant.(none):/ext/mysql/bkroot/mysql-5.0-rpl
into  quant.(none):/ext/mysql/bk/mysql-5.0-bug25306
2007-02-28 08:50:25 +01:00
unknown
71b762bf69 Fix of incorrect merge of test case 2007-02-27 20:57:46 +01:00
unknown
9cf5f2c94a Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.1-opt
into  mysql.com:/home/psergey/mysql-5.1-bug26117
2007-02-27 22:05:52 +03:00
unknown
b68a22019e BUG#26117 "index_merge sort-union over partitioned table crashes"
Before the fix: 
  ha_partition objects had ha_partition::m_part_info==NULL and that caused
  crash
After: 
- The new ha_partition::clone() function makes the clones use parent's
  m_part_info value.
- The parent ha_partition object remains responsible for deallocation of
  m_part_info.


mysql-test/r/partition_innodb.result:
  BUG#26117 "index_merge sort-union over partitioned table crashes"
   - Testcase
mysql-test/t/partition_innodb.test:
  BUG#26117 "index_merge sort-union over partitioned table crashes"
   - Testcase
2007-02-27 22:01:03 +03:00
unknown
f0e5877c53 Merge quant.(none):/ext/mysql/bkroot/mysql-5.0-rpl
into  quant.(none):/ext/mysql/bk/mysql-5.0-bug25306


sql/slave.cc:
  Auto merged
sql/sql_repl.cc:
  Auto merged
2007-02-27 19:38:39 +01:00
unknown
7443227bca Merge mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.1-merge


sql/sql_load.cc:
  Auto merged
mysql-test/r/rpl_user_variables.result:
  Manual merge
mysql-test/t/rpl_user_variables.test:
  Manual merge
sql/item_func.cc:
  Manual merge
sql/log.cc:
  Manual merge
sql/sp_head.cc:
  Manual merge
sql/sql_class.cc:
  Manual merge
sql/sql_class.h:
  Manual merge
2007-02-27 19:20:47 +01:00
unknown
ae72e39450 Fix (last) compiler warnings
storage/innobase/pars/lexyy.c:
  Fix compiler warnings (fix is also in pars0lex.l)
support-files/compiler_warnings.supp:
  Extra safety to ensure we really get rid of warning :)
2007-02-27 20:06:37 +02:00
unknown
0ddc3250e9 Merge mysql.com:/nfsdisk1/lars/MERGE/mysql-4.1-merge
into  mysql.com:/nfsdisk1/lars/MERGE/mysql-5.0-merge


sql/sql_load.cc:
  Manual merge
2007-02-27 18:40:57 +01:00