containing a select statement that uses an aggregating IN subquery.
Added a parameter to the function fix_prepare_information
to restore correctly the having clause for the second execution.
Saved andor structure of the having conditions at the proper moment
before any calls of split_sum_func2 that could modify the having structure
adding new Item_ref objects. (These additions, are produced not with
the statement mem_root, but rather with the execution mem_root.)
mysql-test/r/sp.result:
Added a test case for bug #21493.
mysql-test/t/sp.test:
Added a test case for bug #21493.
sql/sql_delete.cc:
Fixed bug #21493: crash for the second execution of a function
containing a select statement that uses an aggregating IN subquery.
Added a parameter to the function fix_prepare_information
to restore correctly the having clause for the second execution.
sql/sql_insert.cc:
Fixed bug #21493: crash for the second execution of a function
containing a select statement that uses an aggregating IN subquery.
Added a parameter to the function fix_prepare_information
to restore correctly the having clause for the second execution.
sql/sql_lex.cc:
Fixed bug #21493: crash for the second execution of a function
containing a select statement that uses an aggregating IN subquery.
Added a parameter to the function fix_prepare_information
to restore correctly the having clause for the second execution.
sql/sql_lex.h:
Fixed bug #21493: crash for the second execution of a function
containing a select statement that uses an aggregating IN subquery.
Added a parameter to the function fix_prepare_information
to restore correctly the having clause for the second execution.
sql/sql_update.cc:
Fixed bug #21493: crash for the second execution of a function
containing a select statement that uses an aggregating IN subquery.
Added a parameter to the function fix_prepare_information
to restore correctly the having clause for the second execution.
SELECT right instead of INSERT right was required for an insert into to a view.
This wrong behaviour appeared after the fix for bug #20989. Its intention was
to ask only SELECT right for all tables except the very first for a complex
INSERT query. But that patch has done it in a wrong way and lead to asking
a wrong access right for an insert into a view.
The setup_tables_and_check_access() function now accepts two want_access
parameters. One will be used for the first table and the second for other
tables.
mysql-test/t/view.test:
Added a test case for bug#21261: Wrong access rights was required for an insert into a view
mysql-test/r/view.result:
Added a test case for bug#21261: Wrong access rights was required for an insert into a view
sql/sql_update.cc:
Fixed bug#21261: Wrong access rights was required for an insert into a view
Modified to use updated setup_tables_and_check_access() function.
sql/sql_select.cc:
Fixed bug#21261: Wrong access rights was required for an insert into a view
Modified to use updated setup_tables_and_check_access() function.
sql/sql_load.cc:
Fixed bug#21261: Wrong access rights was required for an insert into a view
Modified to use updated setup_tables_and_check_access() function.
sql/sql_insert.cc:
Fixed bug#21261: Wrong access rights was required for an insert into a view
Modified to use updated setup_tables_and_check_access() function.
sql/sql_delete.cc:
Fixed bug#21261: Wrong access rights was required for an insert into a view
Modified to use updated setup_tables_and_check_access() function.
sql/sql_base.cc:
Fixed bug#21261: Wrong access rights was required for an insert into a view
The setup_tables_and_check_access() function now accepts two want_access
parameters. One will be used for the first table and the second for other
tables.
sql/mysql_priv.h:
Fixed bug#21261: Wrong access rights was required for an insert into a view
The setup_tables_and_check_access() function now accepts two want_access
parameters.
REPLACE ... SELECT would require INSERT privileges on certain tables
when SELECT really suffices. Require INSERT only on target table.
mysql-test/r/insert_select.result:
Bug#20989: View '(null).(null)' references invalid table(s)... on SQL SECURITY INVOKER
Show that REPLACE ... SELECT requires INSERT privileges only on target table.
(revised test with more view-fu)
mysql-test/t/insert_select.test:
Bug#20989: View '(null).(null)' references invalid table(s)... on SQL SECURITY INVOKER
Show that REPLACE ... SELECT requires INSERT privileges only on target table.
(revised test with more view-fu)
sql/sql_insert.cc:
Bug#20989: View '(null).(null)' references invalid table(s)... on SQL SECURITY INVOKER
require SELECT rather than INSERT privs on tables that constitute the views we'll read
into moonbone.local:/work/tmp_merge-5.0-opt-mysql
mysql-test/r/rpl_insert_id.result:
Auto merged
mysql-test/t/rpl_insert_id.test:
Auto merged
sql/item_strfunc.cc:
Auto merged
sql/item_strfunc.h:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_select.cc:
Auto merged
into dl145k.mysql.com:/data0/mkindahl/bk/mysql-5.0-rpl
ndb/include/kernel/GlobalSignalNumbers.h:
Auto merged
ndb/src/kernel/blocks/dbdict/Dbdict.cpp:
Auto merged
ndb/src/kernel/blocks/dbdict/Dbdict.hpp:
Auto merged
ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
Auto merged
ndb/src/ndbapi/ndberror.c:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/handler.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
into bodhi.local:/opt/local/work/mysql-5.0-runtime-merge-41
myisam/mi_create.c:
Auto merged
mysql-test/r/myisam.result:
Auto merged
mysql-test/t/myisam.test:
Auto merged
sql/item_timefunc.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_trigger.cc:
Auto merged
support-files/mysql.spec.sh:
Auto merged
mysql-test/r/federated.result:
Manual merge.
mysql-test/t/federated.test:
Manual merge.
into chilla.local:/home/mydev/mysql-5.0-bug16218
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_trigger.cc:
Auto merged
sql/table.cc:
Auto merged
into mysql.com:/home/dlenev/mysql-5.0-bg18437-3
mysql-test/t/federated.test:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/item.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_table.cc:
Auto merged
sql/sql_trigger.cc:
Auto merged
sql/sql_update.cc:
Auto merged
mysql-test/r/federated.result:
Manual merge.
auto_increment breaks binlog":
if slave's table had a higher auto_increment counter than master's (even
though all rows of the two tables were identical), then in some cases,
REPLACE and INSERT ON DUPLICATE KEY UPDATE failed to replicate
statement-based (it inserted different values on slave from on master).
write_record() contained a "thd->next_insert_id=0" to force an adjustment
of thd->next_insert_id after the update or replacement. But it is this
assigment introduced indeterminism of the statement on the slave, thus
the bug. For ON DUPLICATE, we replace that assignment by a call to
handler::adjust_next_insert_id_after_explicit_value() which is deterministic
(does not depend on slave table's autoinc counter). For REPLACE, this
assignment can simply be removed (as REPLACE can't insert a number larger
than thd->next_insert_id).
We also move a too early restore_auto_increment() down to when we really know
that we can restore the value.
mysql-test/r/rpl_insert_id.result:
result update, without the bugfix, slave's "3 350" were "4 350".
mysql-test/t/rpl_insert_id.test:
test for BUG#20188 "REPLACE or ON DUPLICATE KEY UPDATE in
auto_increment breaks binlog".
There is, in this order:
- a test of the bug for the case of REPLACE
- a test of basic ON DUPLICATE KEY UPDATE functionality which was not
tested before
- a test of the bug for the case of ON DUPLICATE KEY UPDATE
sql/handler.cc:
the adjustment of next_insert_id if inserting a big explicit value, is
moved to a separate method to be used elsewhere.
sql/handler.h:
see handler.cc
sql/sql_insert.cc:
restore_auto_increment() means "I know I won't use this autogenerated
autoincrement value, you are free to reuse it for next row". But we were
calling restore_auto_increment() in the case of REPLACE: if write_row() fails
inserting the row, we don't know that we won't use the value, as we are going to
try again by doing internally an UPDATE of the existing row, or a DELETE
of the existing row and then an INSERT. So I move restore_auto_increment()
further down, when we know for sure we failed all possibilities for the row.
Additionally, in case of REPLACE, we don't need to reset THD::next_insert_id:
the value of thd->next_insert_id will be suitable for the next row.
In case of ON DUPLICATE KEY UPDATE, resetting thd->next_insert_id is also
wrong (breaks statement-based binlog), but cannot simply be removed, as
thd->next_insert_id must be adjusted if the explicit value exceeds it.
We now do the adjustment by calling
handler::adjust_next_insert_id_after_explicit_value() (which, contrary to
thd->next_insert_id=0, does not depend on the slave table's autoinc counter,
and so is deterministic).
When compiling INSERT statements the check whether columns are provided values
depends on the flag whether a field is used in that query (Field::query_id).
However the check for updatability of VIEW columns (check_view_insertability())
was calling fix_fields() and thus setting the Field::query_id even for the
view fields that are not referenced in the current INSERT statement.
So the correct check for columns without default values
( check_that_all_fields_are_given_values() ) is assuming that all the VIEW
columns were mentioned in the INSERT field list and was issuing no
warnings or errors.
Fixed check_view_insertability() to turn off the flag whether or not to set
Field::query_id (THREAD::set_query_id) before calling fix fields and restore
it when it's done.
mysql-test/r/view.result:
Bug #16110: insert permitted into view col w/o default value
* test case
mysql-test/t/view.test:
Bug #16110: insert permitted into view col w/o default value
* test case
sql/sql_insert.cc:
Bug #16110: insert permitted into view col w/o default value
* avoid setting the "field used" flag for fields when checking view columns
for updatability.
* a missing DBUG_RETURN added.
NDB table".
SQL-layer was not marking fields which were used in triggers as such. As
result these fields were not always properly retrieved/stored by handler
layer. So one might got wrong values or lost changes in triggers for NDB,
Federated and possibly InnoDB tables.
This fix solves the problem by marking fields used in triggers
appropriately.
Also this patch contains the following cleanup of ha_ndbcluster code:
We no longer rely on reading LEX::sql_command value in handler in order
to determine if we can enable optimization which allows us to handle REPLACE
statement in more efficient way by doing replaces directly in write_row()
method without reporting error to SQL-layer.
Instead we rely on SQL-layer informing us whether this optimization
applicable by calling handler::extra() method with
HA_EXTRA_WRITE_CAN_REPLACE flag.
As result we no longer apply this optimzation in cases when it should not
be used (e.g. if we have on delete triggers on table) and use in some
additional cases when it is applicable (e.g. for LOAD DATA REPLACE).
Finally this patch includes fix for bug#20728 "REPLACE does not work
correctly for NDB table with PK and unique index".
This was yet another problem which was caused by improper field mark-up.
During row replacement fields which weren't explicity used in REPLACE
statement were not marked as fields to be saved (updated) so they have
retained values from old row version. The fix is to mark all table
fields as set for REPLACE statement. Note that in 5.1 we already solve
this problem by notifying handler that it should save values from all
fields only in case when real replacement happens.
include/my_base.h:
Added HA_EXTRA_WRITE_CAN_REPLACE, HA_EXTRA_WRITE_CANNOT_REPLACE - new
parameters for ha_extra() method. We use them to inform handler that
write_row() which tries to insert new row into the table and encounters
some already existing row with same primary/unique key can replace old
row with new row instead of reporting error.
mysql-test/r/federated.result:
Additional test for bug#18437 "Wrong values inserted with a before update
trigger on NDB table".
mysql-test/r/ndb_replace.result:
Added test for bug #20728 "REPLACE does not work correctly for NDB table
with PK and unique index". Updated wrong results from older test.
mysql-test/t/federated.test:
Additional test for bug#18437 "Wrong values inserted with a before update
trigger on NDB table".
mysql-test/t/ndb_replace.test:
Added test for bug #20728 "REPLACE does not work correctly for NDB table
with PK and unique index".
sql/ha_ndbcluster.cc:
We no longer rely on reading LEX::sql_command value in handler in order
to determine if we can enable optimization which allows us to handle REPLACE
statement in more efficient way by doing replaces directly in write_row()
method without reporting error to SQL-layer.
Instead we rely on SQL-layer informing us whether this optimization
applicable by calling handler::extra() method with
HA_EXTRA_WRITE_CAN_REPLACE flag.
As result we no longer apply this optimization in cases when it should not
be used (e.g. if we have on delete triggers on table) and use in some
additional cases when it is applicable (e.g. for LOAD DATA REPLACE).
sql/item.cc:
Item_trigger_field::setup_field():
Added comment explaining why we don't set Field::query_id in this method.
sql/mysql_priv.h:
mysql_alter_table() function no longer takes handle_duplicates argument.
Added declaration of mark_fields_used_by_triggers_for_insert_stmt() function.
sql/sql_delete.cc:
Mark fields which are used by ON DELETE triggers so handler will retrieve
values for these fields.
sql/sql_insert.cc:
Explicitly inform handler that we are doing REPLACE (using ha_extra() method)
in cases when it can promote insert operation done by write_row() to replace.
Also when we do REPLACE we want to store values for all columns so we should
inform handler about it.
Finally we should mark fields used by ON UPDATE/ON DELETE triggers as such
so handler can properly retrieve/restore values in these fields during
execution of REPLACE and INSERT ... ON DUPLICATE KEY UPDATE statements.
sql/sql_load.cc:
Explicitly inform handler that we are doing LOAD DATA REPLACE (using
ha_extra() method) in cases when it can promote insert operation done by
write_row() to replace.
Also when we do replace we want to save (replace) values for all columns
so we should inform handler about it.
Finally to properly execute LOAD DATA for table with triggers we should
mark fields used by ON INSERT triggers as such so handler can properly
store values for these fields.
sql/sql_parse.cc:
mysql_alter_table() function no longer takes handle_duplicates argument.
sql/sql_table.cc:
Got rid of handle_duplicates argument in mysql_alter_table() and
copy_data_between_tables() functions. These functions were always
called with handle_duplicates == DUP_ERROR and thus contained dead
(and probably incorrect) code.
sql/sql_trigger.cc:
Added Table_triggers_list::mark_fields_used() method which is used to mark
fields read/set by triggers as such so handlers will be able properly
retrieve/store values in these fields.
sql/sql_trigger.h:
Table_triggers_list:
Added mark_fields_used() method which is used to mark fields read/set by
triggers as such so handlers will be able properly retrieve/store values
in these fields. To implement this method added 'trigger_fields' member
which is array of lists linking items for all fields used in triggers
grouped by event and action time.
sql/sql_update.cc:
Mark fields which are used by ON UPDATE triggers so handler will retrieve
and save values for these fields.
mysql-test/r/ndb_trigger.result:
Added test for bug#18437 "Wrong values inserted with a before update trigger
on NDB table".
mysql-test/t/ndb_trigger.test:
Added test for bug#18437 "Wrong values inserted with a before update trigger
on NDB table".
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.
Bug#17294 - INSERT DELAYED puting an \n before data
Bug#16611 - INSERT DELAYED corrupts data
Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
Combined as Bug#16218.
INSERT DELAYED crashed in 5.0 on a table with a varchar that
could be NULL and was created pre-5.0 (Bugs 16218 and 13707).
INSERT DELAYED corrupted data in 5.0 on a table with varchar
fields that was created pre-5.0 (Bugs 17294 and 16611).
In case of INSERT DELAYED the open table is copied from the
delayed insert thread to be able to create a record for the
queue. When copying the fields, a method was used that did
convert old varchar to new varchar fields and did not set up
some pointers into the record buffer of the table.
The field conversion was guilty for the misinterpretation of
the record contents by the delayed insert thread. The wrong
pointer setup was guilty for the crashes.
For Bug 13707 (Server crash with INSERT DELAYED on MyISAM table)
I fixed the above mentioned method to set up one of the pointers.
For Bug 16218 I set up the other pointers too.
But when looking at the corruptions I got aware that converting
the field type was totally wrong for INSERT DELAYED. The copied
table is used to create a record that is to be sent to the
delayed insert thread. Of course it can interpret the record
correctly only if all field types are the same in both table
objects.
So I revoked the fix for Bug 13707 and changed the new_field()
method so that it can suppress conversions.
No test case as this is a migration problem. One needs to
create a table with 4.x and use it with 5.x. I added two
test scripts to the bug report.
sql/field.cc:
Bug#16218 - Crash on insert delayed
Bug#17294 - INSERT DELAYED puting an \n before data
Bug#16611 - INSERT DELAYED corrupts data
Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
Combined as Bug#16218.
Added parameter 'keep_type' to Field::new_field().
Undid the change from Bug 13707 (Server crash with INSERT
DELAYED on MyISAM table).
I solved all four bugs in sql/sql_insert.cc by making exact
duplicates of the fields. The new_field() method converts
certain field types, which is wrong for INSERT DELAYED.
sql/field.h:
Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
Combined as Bug#16218.
Added parameter 'keep_type' to Field::new_field().
sql/sql_insert.cc:
Bug#16218 - Crash on insert delayed
Bug#17294 - INSERT DELAYED puting an \n before data
Bug#16611 - INSERT DELAYED corrupts data
Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
Combined as Bug#16218.
Added comments. Made small style fixes.
Used the new parameter 'keep_type' of Field::new_field()
to avoid field type conversion. The table copy must have
exactly the same types of fields as the original table.
Otherwise the record contents created by the foreground
thread could be misinterpreted by the delayed insert thread.
sql/sql_select.cc:
Bug#16218 - Crash on insert delayed
Bug#17294 - INSERT DELAYED puting an \n before data
Bug#16611 - INSERT DELAYED corrupts data
Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
Combined as Bug#16218.
Added parameter 'keep_type' to Field::new_field().
Undid the change from Bug 13707 (Server crash with INSERT
DELAYED on MyISAM table).
I solved all four bugs in sql/sql_insert.cc by making exact
duplicates of the fields. The new_field() method converts
certain field types, which is wrong for INSERT DELAYED.
sql/sql_trigger.cc:
Bug#16218 - Crash on insert delayed
Bug#17294 - INSERT DELAYED puting an \n before data
Bug#16611 - INSERT DELAYED corrupts data
Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
Combined as Bug#16218.
Added parameter 'keep_type' to Field::new_field().
Undid the change from Bug 13707 (Server crash with INSERT
DELAYED on MyISAM table).
I solved all four bugs in sql/sql_insert.cc by making exact
duplicates of the fields. The new_field() method converts
certain field types, which is wrong for INSERT DELAYED.
sql/table.cc:
Bug#16218 - Crash on insert delayed
Bug#17294 - INSERT DELAYED puting an \n before data
Bug#16611 - INSERT DELAYED corrupts data
Bug#13707 - Server crash with INSERT DELAYED on MyISAM table
Combined as Bug#16218.
Added parameter 'keep_type' to Field::new_field().
Undid the change from Bug 13707 (Server crash with INSERT
DELAYED on MyISAM table).
I solved all four bugs in sql/sql_insert.cc by making exact
duplicates of the fields. The new_field() method converts
certain field types, which is wrong for INSERT DELAYED.
Addendum fixes after changing the condition variable
for the global read lock.
The stress test suite revealed some deadlocks. Some were
related to the new condition variable (COND_global_read_lock)
and some were general problems with the global read lock.
It is now necessary to signal COND_global_read_lock whenever
COND_refresh is signalled.
We need to wait for the release of a global read lock if one
is set before every operation that requires a write lock.
But we must not wait if we have locked tables by LOCK TABLES.
After setting a global read lock a thread waits until all
write locks are released.
mysql-test/r/lock_multi.result:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Added test results.
mysql-test/t/lock_multi.test:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Added tests for possible deadlocks that did not occur
with the stress test suite.
mysys/thr_lock.c:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Added a protection against an infinite loop that occurs
with the test case for Bug #20662.
sql/lock.cc:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Signal COND_global_read_lock whenever COND_refresh
is signalled by using the new function broadcast_refresh().
Added the definition of a new function that signals
COND_global_read_lock whenever COND_refresh is signalled.
sql/mysql_priv.h:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Added a declaration for a new function that signals
COND_global_read_lock whenever COND_refresh is signalled.
sql/sql_base.cc:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Signal COND_global_read_lock whenever COND_refresh
is signalled by using the new function broadcast_refresh().
sql/sql_handler.cc:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Signal COND_global_read_lock whenever COND_refresh
is signalled by using the new function broadcast_refresh().
sql/sql_insert.cc:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Removed global read lock handling from inside of
INSERT DELAYED. It is handled on a higher level now.
sql/sql_parse.cc:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Wait for the release of a global read lock if one is set
before every operation that requires a write lock.
But don't wait if locked tables exist already.
sql/sql_table.cc:
Bug#16986 - Deadlock condition with MyISAM tables
Addendum fixes after changing the condition variable
for the global read lock.
Removed global read lock handling from inside of
CREATE TABLE. It is handled on a higher level now.
Signal COND_global_read_lock whenever COND_refresh
is signalled by using the new function broadcast_refresh().
INSERT triggers".
In cases when REPLACE was internally executed via update and table had
on update (on delete) triggers defined we exposed the fact that such
optimization used by callng on update (not calling on delete) triggers.
Such behavior contradicts our documentation which describes REPLACE as
INSERT with optional DELETE.
This fix just disables this optimization for tables with on delete triggers.
The optimization is still applied for tables which have on update but have
no on delete triggers, we just don't invoke on update triggers in this case
and thus don't expose information about optimization to user.
Also added test coverage for values returned by ROW_COUNT() function (and
thus for values returned by mysql_affected_rows()) for various forms of
INSERT.
mysql-test/r/insert.result:
Added test for values returned by ROW_COUNT() function (and thus for values
returned by mysql_affected_rows()) for various forms of INSERT. We didn't
have coverage for this before and since this fix touches related code it is
better to add it now.
mysql-test/r/trigger.result:
Adjusted test after fixing bug#13479 "REPLACE activates UPDATE trigger, not
the DELETE and INSERT triggers".
mysql-test/t/insert.test:
Added test for values returned by ROW_COUNT() function (and thus for values
returned by mysql_affected_rows()) for various forms of INSERT. We didn't
have coverage for this before and since this fix touches related code it is
better to add it now.
mysql-test/t/trigger.test:
Adjusted test after fixing bug#13479 "REPLACE activates UPDATE trigger, not
the DELETE and INSERT triggers".
sql/sql_insert.cc:
write_record():
We should not expose that internally we sometimes execute REPLACE
via UPDATE instead of documented INSERT + DELETE pair. So we should not
use this optimization for tables with on delete triggers. OTOH it is ok
to use it for tables which have on update but have no on delete triggers,
we just should not invoke on update triggers in this case.
The INSERT DELAYED should not maintain its own private auto-increment
counter, because this is assuming that other threads cannot insert
into the table while the INSERT DELAYED thread is inserting, which is
a wrong assumption.
So the start of processing of a batch of INSERT rows in the
INSERT DELAYED thread must be treated as a start of a new statement
and cached next_insert_id must be cleared.
mysql-test/r/delayed.result:
test suite for the bug
mysql-test/t/delayed.test:
test suite for the bug
sql/sql_insert.cc:
Reset auto-increment cacheing before processing
the next batch of inserts in the handler thread
into mysql.com:/home/kgeorge/mysql/5.0/B18681
sql/mysql_priv.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_select.cc:
Auto merged
The check for view security was lacking several points :
1. Check with the right set of permissions : for each table ref that
participates in a view there were the right credentials to use in it's
security_ctx member, but these weren't used for checking the credentials.
This makes hard enforcing the SQL SECURITY DEFINER|INVOKER property
consistently.
2. Because of the above the security checking for views was just ruled out
in explicit ways in several places.
3. The security was checked only for the columns of the tables that are
brought into the query from a view. So if there is no column reference
outside of the view definition it was not detecting the lack of access to
the tables in the view in SQL SECURITY INVOKER mode.
The fix below tries to fix the above 3 points.
mysql-test/r/grant.result:
removed nondeterminism (unspecified order) in some test output
mysql-test/r/view_grant.result:
Somewhat extended test case for the bug and similar queries.
mysql-test/t/grant.test:
removed nondeterminism (unspecified order) in some test output
mysql-test/t/view_grant.test:
Somewhat extended test case for the bug and similar queries.
sql/mysql_priv.h:
A wrapper for setup_tables that also checks access to the tables
sql/sql_acl.cc:
removed artificial security check stop and used the table ref's credentials.
sql/sql_base.cc:
a wrapper for setup_tables to check access to the tables
sql/sql_delete.cc:
wrapper called.
sql/sql_insert.cc:
wrapper called
sql/sql_load.cc:
wrapper called
sql/sql_parse.cc:
wrapper called and artificial check stop removed
sql/sql_select.cc:
wrapper called
sql/sql_update.cc:
wrapper called
sql/table.cc:
Mask table access to the view error as well.
Fixed compiler warnings
Fixed valgrind warning in Item_date_add_intervall::eq. (Recoding of bugfix #19490)
sql/field.cc:
remove dflt_field from field structure (not needed)
Simple cleanup of code that been copied elsewhere
sql/field.h:
remove dflt_field from field structure (not needed)
sql/item.h:
Removed compiler warnings
sql/item_timefunc.cc:
Fixed Item_date_add_intervall::eq
The problem was that when we call 'eq' 'this' is not fixed, which means we can't call const_item() or a value function.
I fixed this so that we check eq for all arguments and that the sign and type are identical.
(The original code gave a 'accessing uninitialized data' in valgrind.
sql/mysql_priv.h:
Added default fields to create_tmp_field
sql/sql_insert.cc:
New default_field parameter to create_tmp_field()
sql/sql_select.cc:
New default_field parameter to create_tmp_field()
Use this in create_tmp_table() to set right default value for a field
into mysql.com:/home/dlenev/mysql-5.0-bg12472
sql/mysql_priv.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_table.cc:
Auto merged
mysql-test/r/sp.result:
Manual merge.
mysql-test/t/sp.test:
Manual merge.
or implicitly uses stored function gives "Table not locked" error'
CREATE TABLE ... SELECT ... statement which was explicitly or implicitly
(through view) using stored function gave "Table not locked" error.
The actual bug resides in the current locking scheme of CREATE TABLE SELECT
code, which first opens and locks tables of the SELECT statement itself,
and then, having SELECT tables locked, creates the .FRM, opens the .FRM and
acquires lock on it. This scheme opens a possibility for a deadlock, which
was present and ignored since version 3.23 or earlier. This scheme also
conflicts with the invariant of the prelocking algorithm -- no table can
be open and locked while there are tables locked in prelocked mode.
The patch makes an exception for this invariant when doing CREATE TABLE ...
SELECT, thus extending the possibility of a deadlock to the prelocked mode.
We can't supply a better fix in 5.0.
mysql-test/r/sp.result:
Added tests for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which
explicitly or implicitly uses stored function gives "Table not locked" error'
mysql-test/t/sp.test:
Added tests for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which
explicitly or implicitly uses stored function gives "Table not locked" error'
sql/mysql_priv.h:
Added flag which can be passed to open_table() routine in order to ignore
set of locked tables and prelocked mode.
We don't need declaration of create_table_from_items() any longer as it was
moved into sql_insert.cc and made static.
sql/sql_base.cc:
open_table():
Added flag which allows open table ignoring set of locked tables and
prelocked mode.
sql/sql_insert.cc:
Moved create_table_from_items() from sql_table.cc to sql_insert.cc as it was
not used outside of sql_insert.cc and contains code which is specific for
CREATE TABLE ... SELECT.
Also now when we are executing CREATE TABLE ... SELECT ... statement which
SELECT part requires execution in prelocked mode we ignore set of locked
tables in order to get access to the table we just have created.
We probably don't want to do this if we are under real LOCK TABLES since
it will widen window for deadlock too much.
sql/sql_table.cc:
Moved create_table_from_items() routine into sql_insert.cc, since it was not
used anywhere outside of this file and contains logic which is specific for
CREATE TABLE ... SELECT statement.
Additional fix for INSERT DELAYED with subselect.
Originally detected in 5.1, but 5.0 could also be affected.
The user thread creates a dummy table object,
which is not included in the lock. The 'real' table is
opened and locked by the 'delayed' system thread.
The dummy object is now marked as not locked and this is
tested in mysql_lock_have_duplicate().
sql/lock.cc:
BUG#5390 - problems with merge tables
Additional fix for INSERT DELAYED with subselect.
The user thread creates a dummy table object,
which is not included in the lock.
Changed to safer asserts.
sql/sql_insert.cc:
BUG#5390 - problems with merge tables
Marked the dummy table object as not being
included in the lock.
The bug was caused by wrong behaviour of mysql_insert() which in case
of INSERT DELAYED into a view exited with thd->net.report_error == 0.
This blocked error reporting to the client which started waiting
infinitely for response to the query.
mysql-test/r/insert.result:
Fixed results for the added test case.
mysql-test/t/insert.test:
Added test case.
sql/sql_insert.cc:
Fixed BUG#13683: INSERT DELAYED into a view creates an infinite loop.
Changed mysql_insert(): delayed_get_table() applied to a view exits
with ER_WRONG_OBJECT error (and with thd->net.report_error == 1) and
in this case we must just exit from mysql_insert(). Prior to this
change, instead of exiting open_and_lock_tables() was invoked which
cleared thd->net.report_error to zero and caused the bug.
into mysql.com:/home/dlenev/mysql-5.0-bg17764
mysql-test/r/trigger.result:
Auto merged
mysql-test/t/trigger.test:
Auto merged
sql/sql_insert.cc:
Auto merged
A table with an on insert trigger was reported as crashed when the insert
was processed with bulk insert mode on (handler::start_bulk_insert).
The trigger was also selecting from the same table, and that caused
the "crash".
The same problem was present when an insert statement, which was processed
in bulk mode, also used a stored function that was reading the same table.
This fix disables bulk inserts if a statement uses functions or invokes
triggers. Implementing more granular checks will require much more code and
therefore can hardly be done in 5.0
mysql-test/r/trigger.result:
Added test bug #17764 "Trigger crashes MyISAM table".
mysql-test/t/trigger.test:
Added test bug #17764 "Trigger crashes MyISAM table".
sql/sql_insert.cc:
We should not start bulk inserts for INSERT (or similar) statement if it uses
functions or invokes triggers since they may access to the same table and
therefore should not see its inconsistent state created by this optimization.
sql/sql_load.cc:
We should not start bulk inserts for INSERT (or similar) statement if it uses
functions or invokes triggers since they may access to the same table and
therefore should not see its inconsistent state created by this optimization.
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.
sql/field.cc:
Auto merged
sql/item.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_handler.cc:
ur
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())
myisam/mi_delete.c:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
sql/item_func.cc:
Auto merged
sql/opt_range.cc:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_db.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_show.cc:
Auto merged
into mysql.com:/home/mydev/mysql-5.0-bug5390
BitKeeper/deleted/.del-ha_blackhole.cc~727c69ef7846623a:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_delete.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_update.cc:
Auto merged
Problem #1: INSERT...SELECT, Version for 5.0.
Extended the unique table check by a check of lock data.
Merge sub-tables cannot be detected by doing name checks only.
mysql-test/r/create.result:
BUG#5390 - problems with merge tables
Removed a duplicate test.
mysql-test/r/merge.result:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT
Added test results.
mysql-test/t/create.test:
BUG#5390 - problems with merge tables
Removed a duplicate test.
mysql-test/t/merge.test:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT
Added tests.
sql/lock.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added a new function to find a duplicate lock in a list of tables.
sql/mysql_priv.h:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
Added a declaration for the new function.
sql/sql_base.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
Added a call to the new mysql_lock_have_duplicate(),
which needs the thread handle, to unique_table().
sql/sql_delete.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
sql/sql_insert.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
sql/sql_load.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
sql/sql_parse.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
sql/sql_update.cc:
BUG#5390 - problems with merge tables
Problem #1: INSERT...SELECT, Version for 5.0.
Added the thread handle to unique_table().
Replaced a call to find_table_in_local_list() by
the newly extended unique_table().
handling so that indexes are closed before trying to commit the
transaction. (Bug #15536)
mysql-test/r/bdb.result:
Add new results
mysql-test/t/bdb.test:
Add new test
sql/sql_delete.cc:
Move call to free_underlaid_joins() to before ha_autocommit_or_rollback().
sql/sql_insert.cc:
Move call to free_underlaid_joins() to before ha_autocommit_or_rollback().
sql/sql_update.cc:
Move call to free_underlaid_joins() to before ha_autocommit_or_rollback().
Post-review fixes according to Monty's review.
sql/item.h:
Unite all code that stores and restores the state of a name resolution context
into a class to represent the state, and methods to save/restore that
state.
sql/mysql_priv.h:
Reorder parameters so that length is after the name of a field,
and database is before table name.
sql/sql_acl.cc:
Reorder parameters so that length is after the name of a field,
and database is before table name.
sql/sql_base.cc:
* Reorder parameters so that length is after the name of a field,
and database is before table name.
* Added new method - Field_iterator_table_ref::get_natural_column_ref
to avoid unnecessary code when it is knwon that no new columns will
be created when accessing natural join columns.
sql/sql_insert.cc:
Unite all code that stores and restores the state of a name resolution context
into a class to represent the state, and methods to save/restore that
state.
sql/sql_lex.cc:
Removed obsolete comment.
sql/sql_lex.h:
Return error from push_contex() if there is no memory.
sql/sql_list.h:
Extended base_list_iterator, List_iterator, and List_iterator_fast with an
empty constructor, and init() methods, so that one doesn't have to construct
a new iterator object every time one needs to iterate over a new list.
sql/sql_parse.cc:
Moved common functionality from the parser into one function, and renamed
the function to better reflect what it does.
sql/sql_yacc.yy:
Moved common functionality from the parser into one function, and renamed
the function to better reflect what it does.
sql/table.cc:
* Extended base_list_iterator, List_iterator, and List_iterator_fast with an
empty constructor, and init() methods, so that one doesn't have to construct
a new iterator object every time one needs to iterate over a new list.
* Added new method Field_iterator_table_ref::get_natural_column_ref to be
used in cases when it is known for sure that no new columns should be
created.
sql/table.h:
- column_ref_it no longer allocated for each new list of columns
- new method get_natural_join_column for faster/simpler access
to natural join columns.
check_stack_overrun().
sql/slave.cc:
Move initialization of THD::thread_stack before THD::store_globals()
sql/sql_acl.cc:
Initialize THD::thread_stack in artificial THDs used
to load gratns subsystem.
sql/sql_class.cc:
Add an assert that THD::thread_stack is assigned.
sql/sql_insert.cc:
Add initialization of THD::thread_stack (delayed insert
thread).
sql/sql_parse.cc:
Move initialization of THD::thread_stack before
THD::store_globals().
sql/sql_udf.cc:
Add initialization for THD::thread_stack (an artificial
THD used to initialize UDF subsystem).
sql/tztime.cc:
Add initialization for THD::thread_stack (an artificial
THD used to initialize timezones).
into mysql.com:/home/my/mysql-5.0
mysql-test/r/view.result:
Auto merged
mysql-test/t/view.test:
Auto merged
server-tools/instance-manager/instance.cc:
Auto merged
sql/ha_ndbcluster.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/item.cc:
Auto merged
sql/slave.cc:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_manager.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/table.cc:
Auto merged
sql/unireg.cc:
Auto merged
- CHAR() now returns binary string as default
- CHAR(X*65536+Y*256+Z) is now equal to CHAR(X,Y,Z) independent of the character set for CHAR()
- Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
(Some old systems returns ETIME and it's safer to test for both values
than to try to write a wrapper for each old system)
- Fixed new introduced bug in NOT BETWEEN X and X
- Ensure we call commit_by_xid or rollback_by_xid for all engines, even if one engine has failed
- Use octet2hex() for all conversion of string to hex
- Simplify and optimize code
client/mysqldump.c:
Simple optimizations of new code
Indentation fixes
client/mysqltest.c:
Removed not needed variable
include/mysql_com.h:
Made octec2hex() more usable
mysql-test/r/ctype_utf8.result:
CHAR() now returns binary string as default
mysql-test/r/func_str.result:
CHAR() now returns binary string as default
mysql-test/r/range.result:
Added test to verify new introduced bug in NOT BETWEEN X and X
mysql-test/r/user_var-binlog.result:
CHAR() now returns binary string as default
mysql-test/r/view.result:
More tests of view rename
mysql-test/t/ctype_utf8.test:
CHAR() now returns binary string as default
mysql-test/t/func_str.test:
CHAR() now returns binary string as default
mysql-test/t/range.test:
Added test to verify new introduced bug in NOT BETWEEN X and X
mysql-test/t/view.test:
More tests of view rename
mysys/mf_keycache.c:
Indentation changes
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
mysys/my_os2cond.c:
Fix to MySQL coding style
Optimized functions
mysys/thr_lock.c:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
mysys/thr_mutex.c:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
server-tools/instance-manager/instance.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
server-tools/instance-manager/thread_registry.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/ha_federated.cc:
Use octet2hex()
sql/ha_ndbcluster.cc:
Removed not used variable
sql/handler.cc:
Simplify code
Use *NONE* instead of 'none' for not existing storage engine
Ensure we call commit_by_xid or rollback_by_xid for all engines, even if one engine has failed
sql/item.h:
Remove not needed test for *ref. (If ref is set, it should never point at 0)
sql/item_func.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
Simplify code
More comments
Require that last argument to find_and_check_access() is given
(Made code shorter and faster)
sql/item_strfunc.cc:
Changed CHAR() to return result in binary collation
CHAR(X*65536+Y*256+Z) is now equal to CHAR(X,Y,Z) independent of the character set for CHAR()
Bar will shortly add the following syntax:
CHAR(.... USING character_set)
and ensure that
CONVERT(CHAR(....) USING utf8) cuts not legal utf8 strings
Use ocet2hex()
sql/item_strfunc.h:
CHAR() now returns a binary string
sql/log_event.cc:
Use octet2hex()
Simplify code
sql/parse_file.cc:
Indentation fixes
Use for() instead of while()
sql/password.c:
Make octet2hex() more generally usable by returning pointer to end 0
sql/slave.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_base.cc:
Indentation fixes
sql/sql_insert.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_manager.cc:
Test for both ETIMEDOUT and ETIME from pthread_cond_timedwait()
sql/sql_parse.cc:
Don't check thd->db when checking for function privileges
sql/sql_prepare.cc:
Fixed wrong merge
sql/sql_select.cc:
Fixed new bug for NOT BETWEEN X and X
sql/sql_show.cc:
Removed not used variable
sql/sql_table.cc:
Indentation fixed
Removed DBUG_PRINT that is obvious from context
sql/sql_view.cc:
Simplify code
sql/unireg.cc:
Use octet2hex()
This bug occurs when some trigger for table used by DML statement is created
or changed while statement was waiting in lock_tables(). In this situation
prelocking set which we have calculated becames invalid which can easily lead
to errors and even in some cases to crashes.
With proposed patch we no longer silently reopen tables in lock_tables(),
instead caller of lock_tables() becomes responsible for reopening tables and
recalculation of prelocking set.
mysql-test/t/trigger.test:
Added tests for bug #12704 "Server crashes during trigger execution".
Unfortunately these tests rely on the order in which tables are locked
by statement so they are non-determenistic and therefore should be disabled.
sql/lock.cc:
mysql_lock_tables():
Now instead of always reopening altered or dropped tables by itself
mysql_lock_tables() can notify upper level and rely on caller doing this.
sql/mysql_priv.h:
Now mysql_lock_tables() can either reopen deleted or altered tables by itself
or notify caller about such situation through 'need_reopen' argument and rely
on it in this.
Also lock_tables() has new 'need_reopen' out parameter through which it
notifies caller that some tables were altered or dropped so he needs to reopen
them (and rebuild prelocking set some triggers may change or simply appear).
sql/sp.cc:
sp_add_used_routine():
To be able to restore LEX::sroutines_list to its state right after parsing
we now adjust LEX::sroutines_list_own_last/sroutines_list_own_elements when
we add directly used routine.
sp_remove_not_own_routines():
Added procedure for restoring LEX::sroutines/sroutines_list to their state
right after parsing (by throwing out non-directly used routines).
sp_cache_routines_and_add_tables_for_view()/sp_update_stmt_used_routines():
We should use LEX::sroutines_list instead of LEX::sroutines as source of
routines used by view, since LEX::sroutines is not availiable for view
on second attempt to open it (see comment in open_tables() about it).
sql/sp.h:
sp_remove_not_own_routines():
Added procedure for restoring LEX::sroutines/sroutines_list to their state
right after parsing (by throwing out non-directly used routines).
sql/sp_head.cc:
Removed assert which is no longer always true.
sql/sql_base.cc:
reopen_table():
When we re-open table and do shallow copy of TABLE object we should adjust
pointers to it in associated Table_triggers_list object. Removed nil
operation.
open_tables():
Now this function is able to rebuild prelocking set for statement if it is
needed. It also correctly handles FLUSH TABLES which may occur during its
execution.
lock_tables():
Instead of allowing mysql_lock_tables() to silently reopen altered or dropped
tables let us notify caller and rely on that it will do reopen itself.
This solves the problem when trigger suddenly appears or changed during
mysq_lock_tables().
close_tables_for_reopen():
Added routine for properly preparing for reopening of tables and recalculation
of set of prelocked tables.
sql/sql_handler.cc:
Here we let mysql_lock_tables() to reopen dropped or altered tables by itself.
sql/sql_insert.cc:
Here we let mysql_lock_tables() to reopen dropped or altered tables by itself.
sql/sql_lex.cc:
LEX:
Added 'sroutines_list_own_last' and 'sroutines_list_own_elements' members
which are used for keeping state in which 'sroutines_list' was right after
statement parsing (and for restoring of this list to this state).
sql/sql_lex.h:
LEX:
Added 'sroutines_list_own_last' and 'sroutines_list_own_elements' members
which are used for keeping state in which 'sroutines_list' was right after
statement parsing (and for restoring of this list to this state).
Added chop_off_not_own_tables() method to simplify throwing away list
of implicitly used (prelocked) tables.
sql/sql_prepare.cc:
Now instead of silently reopening altered or dropped tables in
lock_tables() we notify caller and rely on that the caller will
reopen tables.
sql/sql_table.cc:
Here we let mysql_lock_tables() to reopen dropped or altered tables by itself.
sql/sql_trigger.cc:
Added Table_triggers_list::set_table() method to adjust Table_triggers_list
to new pointer to TABLE instance.
sql/sql_trigger.h:
Added Table_triggers_list::set_table() method to adjust Table_triggers_list
to new pointer to TABLE instance.
sql/sql_update.cc:
Now instead of silently reopening altered or dropped tables in
lock_tables() we notify caller and rely on that the caller will
reopen tables.
mysql-test/t/lowercase_view.test:
error code changed after merege
mysql-test/t/view.test:
error code changed after merege
sql/item.cc:
inline function used instead of frequently used expression
removed old TODO
sql/sql_base.cc:
layoutfixed
inline function used instead of frequently used expression
sql/sql_insert.cc:
inline function used instead of frequently used expression