Commit graph

816 commits

Author SHA1 Message Date
Sergey Petrunya
201fb06db9 Merge in fix for BUG#727667 2011-03-25 12:47:44 +03:00
Michael Widenius
139a2b64bf Merge with 5.2 2011-03-09 15:47:59 +02:00
Sergey Petrunya
76165dc760 BUG#727667 Wrong result with OR + NOT NULL in maria-5.3
- put the code that sets HA_NULL_PART bit back
- Fix test_if_ref/part_of_refkey() so that 
  = NULL-ability of lookup columns does not prevent the equality 
    from being removed (we now have early/late NULLs filtering which 
    will filter out NULL values)
  = equality is not removed if it is ref_or_null access, and the value 
    of the lookup column can alternate between the lookup value and NULL.
2011-03-05 12:56:22 +03:00
Michael Widenius
3358cdd504 Merge with 5.1 to get in changes from MySQL 5.1.55 2011-02-28 19:39:30 +02:00
Michael Widenius
869f5d0e81 Merge with alias as String 2011-02-28 13:16:17 +02:00
Michael Widenius
ff3da0f963 Change TABLE->alias to String for less memory reallocation
Changed some String.ptr() -> String.c_ptr() for String that are not guaranteed to end with \0
Removed some c_ptr() usage from parameters to functions that takes ptr & length
Use preallocate buffers to avoid calling malloc() for most operations. 


sql/event_db_repository.cc:
  alias is now a String
sql/event_scheduler.cc:
  c_ptr -> c_ptr_safe() to avoid warnings from valgrind.
sql/events.cc:
  c_ptr -> c_ptr_safe() to avoid warnings from valgrind.
  c_ptr -> ptr() as function takes ptr & length
sql/field.cc:
  alias is now a String
sql/field.h:
  alias is now a String
sql/ha_partition.cc:
  alias is now a String
sql/handler.cc:
  alias is now a String
  ptr() -> c_ptr() as string is not guaranteed to be \0 terminated
sql/item.cc:
  Store error parameter in separarte buffer to ensure correct error message
sql/item_func.cc:
  ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated
sql/item_sum.h:
  Use my_strtod() instead of my_atof() to not have to make string \0 terminated
sql/lock.cc:
  alias is now a String
sql/log.cc:
  c_ptr() -> ptr() as function takes ptr & length
sql/log_event.cc:
  c_ptr_quick() -> ptr() as we only want to get the pointer to String buffer
sql/opt_range.cc:
  ptr() -> c_ptr() as string is not guaranteed to be \0 terminated
sql/opt_table_elimination.cc:
  alias is now a String
sql/set_var.cc:
  ptr() -> c_ptr() as string is not guaranteed to be \0 terminated
  c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
  c_ptr() -> ptr() as function takes ptr & length
  Simplify some code.
sql/sp.cc:
  c_ptr() -> ptr() as function takes ptr & length
sql/sp_rcontext.cc:
  alias is now a String
sql/sql_base.cc:
  alias is now a String.
  Here we win a realloc() for most alias usage.
sql/sql_class.cc:
  Use size descriptor for printf() to avoid accessing bytes outside of buffer
sql/sql_insert.cc:
  Change allocation of TABLE as it's now contains a String
  _ptr() -> ptr() as function takes ptr & length
sql/sql_load.cc:
  Use preallocate buffers to avoid calling malloc() for most operations.
sql/sql_parse.cc:
  Use c_ptr_safe() to ensure string is \0 terminated.
sql/sql_plugin.cc:
  c_ptr_quick() -> ptr() as function takes ptr & length
sql/sql_select.cc:
  alias is now a String
sql/sql_show.cc:
  alias is now a String
sql/sql_string.h:
  Added move() function to change who owns the string (owner does the free)
sql/sql_table.cc:
  alias is now a String
  c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
sql/sql_test.cc:
  c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
  alias is now a String
sql/sql_trigger.cc:
  c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
  Use field->init() to setup pointers to alias.
sql/sql_update.cc:
  alias is now a String
sql/sql_view.cc:
  ptr() -> c_ptr_safe() as string is not guaranteed to be \0 terminated
sql/sql_yacc.yy:
  r() -> c_ptr() as string is not guaranteed to be \0 terminated
sql/table.cc:
  alias is now a String
sql/table.h:
  alias is now a String
storage/federatedx/ha_federatedx.cc:
  Remove extra 1 byte alloc that is automaticly done by strmake()
  Ensure that error message ends with \0
storage/maria/ha_maria.cc:
  alias is now a String
storage/myisam/ha_myisam.cc:
  alias is now a String
2011-02-28 12:48:50 +02:00
Michael Widenius
d46aee702e Fixed compiler and build error:
- Fixed main.mysqlcheck error on windows
- Fixed 'can't drop database pbxt' failure when running pbxt.mysqlslap


sql/table.cc:
  When using not legal file names for checking a non existing table, one got a warning in the log file which caused mysql.mysqlcheck to fail
storage/innodb_plugin/row/row0upd.c:
  Fixed compiler warning
storage/pbxt/src/table_xt.cc:
  Remove table that is dropped from 'repair-pending'.
  Fixed 'can't drop database pbxt' failure when running pbxt.mysqlslap
2011-02-25 17:45:53 +02:00
Michael Widenius
4ad6d6b6c9 Merge in new handler and handlersocket code into 5.3 main 2011-02-22 11:15:47 +02:00
Igor Babaev
ec368ab9fa Merge 2011-01-21 22:48:28 -08:00
Sergey Petrunya
da5db2e19f Backport of:
3723 oystein.grovlen@sun.com   2009-11-23
Bug#46548 (addendum)
Remove KEY::extra_length.  It is not in use.
2011-01-14 12:55:03 +03:00
Michael Widenius
050c004f5e Merge with 5.1
Fixes to get Aria handler tests to work.
Fixes LP#697597 "HANDLER + Aria asserts in maria-5.3-handler"
2011-01-11 15:36:41 +02:00
Igor Babaev
af800fd92f The patch adds the code that allows to use equi-join conditions
for hash join in the cases when there are no suitable indexes
for these conditions.
2011-01-04 21:59:41 -08:00
Sergei Golubchik
31a78529bc virtual columns:
* move a capability from a virtual handler method to table_flags()
 * rephrase error messages to avoid hard-coded English parts
 * admit in test cases that they need xtradb, not innodb

mysql-test/suite/vcol/t/rpl_vcol.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_blocked_sql_funcs_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_column_def_options_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_handler_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_ins_upd_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_keys_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_non_stored_columns_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_partition_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_select_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_supported_sql_funcs_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_trigger_sp_innodb.test:
  this test needs xtradb, it will fail with innodb
mysql-test/suite/vcol/t/vcol_view_innodb.test:
  this test needs xtradb, it will fail with innodb
sql/ha_partition.h:
  check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
sql/handler.h:
  check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
sql/share/errmsg.txt:
  no hard-coded english parts in the error messages (ER_UNSUPPORTED_ACTION_ON_VIRTUAL_COLUMN)
sql/sql_table.cc:
  no hard-coded english parts in the error messages
sql/table.cc:
  * check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
  * no "csv workaround" is needed
  * no hard-coded english parts in the error messages
storage/maria/ha_maria.cc:
  check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
storage/maria/ha_maria.h:
  check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
storage/myisam/ha_myisam.cc:
  check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
storage/myisam/ha_myisam.h:
  check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
storage/xtradb/handler/ha_innodb.cc:
  check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
storage/xtradb/handler/ha_innodb.h:
  check_if_supported_virtual_columns() -> HA_CAN_VIRTUAL_COLUMNS
2010-12-31 10:39:14 +01:00
Michael Widenius
b7b25dc666 Merge with 5.1-release.
- Fixed problem with oqgraph and 'make dist'

Note that after this merge we have a problem show in join_outer where we examine too many rows in one specific case (related to BUG#57024).
This will be fixed when mwl#128 is merged into 5.3.
2010-12-06 10:25:44 +02:00
Michael Widenius
1e5061fe3b merge with 5.1 2010-11-30 23:11:03 +02:00
Michael Widenius
7c56b08216 Added TRASH() to table->record[0] to find out if we access not initialzed data.
- Changed Cached_item_field not copy data for fields with NULL value
- In key_copy() and key_restore() don't copy data for fields with NULL value

Fixed code to avoid valgrind warnings
- Use c_ptr_safe instead of c_ptr()

Removed "QQ" from comments (QQ was ment to be used for internal comments that should be removed before pushing)
Fixed wrong alias used (from previous patch)


sql/event_db_repository.cc:
  Update testing if event table is valid (to avoid valgrind errors)
sql/ha_partition.cc:
  m_ordered_scan_ongoing was not initialized
  Reset null bits in record to avoid valgrind errors
sql/handler.h:
  Added flag if storage engine will write row verbatim and the row contains varchar or null fields
  (in which case we must clear the row to avoid valgrind warnings)
sql/item_buff.cc:
  Changed Cached_item_field not copy data for fields with NULL value
  (Optimization and avoids valgrind warnings)
sql/item_func.cc:
  c_ptr() -> c_ptr_safe()
sql/key.cc:
  In key_copy() and key_restore() don't copy data for fields with NULL value
sql/opt_range.cc:
  c_ptr() -> c_ptr_safe()
sql/sql_base.cc:
  Added TRASH() to table->record[0] to find out if we access not initialzed data.
  Initialize null_bytes to:
  - Get consistent tests
  - Ensure we don't get valgrind warnings for null fields (as we may only update a couple of bits in a byte)
sql/sql_class.cc:
  Removed "QQ" from comments
sql/sql_insert.cc:
  Initialize row to default values if we are using valgrind and row will be copied verbatim to disk in storage engine.
sql/sql_load.cc:
  QQ -> TODO
sql/sql_parse.cc:
  Removed old not used code marked QQ and withing "#ifdef REMOVED"
sql/sql_select.cc:
  QQ -> TODO
  Initialize some variables that was used uninitialized
  Added DBUG_ASSERT() to find out if thd was not properly initialized for sub queries
sql/sql_test.cc:
  Fixed format for printing to DBUG file
  Fixed wrong alias used (from previous patch)
sql/sql_trigger.h:
  QQ -> TODO
sql/table.cc:
  QQ -> TODO
storage/maria/ha_maria.cc:
  Mark table with HA_RECORD_MUST_BE_CLEAN_ON_WRITE, if row is written verbatim to disk and contains varchar or null fields.
storage/maria/ma_open.c:
  Added flags if table has varchar or null fields
storage/maria/maria_def.h:
  Added flags if table has varchar or null fields
storage/myisam/ha_myisam.cc:
  Mark table with HA_RECORD_MUST_BE_CLEAN_ON_WRITE, if row is written verbatim to disk and contains varchar or null fields.
storage/myisam/mi_open.c:
  Fixed memory overrun bug when using fulltext keys
storage/xtradb/row/row0sel.c:
  Removed initialization of null bits. (not needed anymore)
2010-11-27 17:29:52 +02:00
Michael Widenius
52090a4434 Code cleanup to get fewer reallocs() during execution.
- Changed TABLE->alias to String to get fewer reallocs when alias are used.
- Preallocate some buffers

Changed some String->c_ptr() -> String->ptr() when \0 is not needed.
Fixed wrong usage of String->ptr() when we need a \0 terminated string.
Use my_strtod() instead of my_atof() to avoid having to add \0 to string.
c_ptr() -> c_ptr_safe() to avoid warnings from valgrind.
zr 

sql/event_db_repository.cc:
  Update usage of TABLE->alias
sql/event_scheduler.cc:
  c_ptr() -> c_ptr_safe()
sql/events.cc:
  c_ptr() -> ptr() as \0 was not needed
sql/field.cc:
  Update usage of TABLE->alias
sql/field.h:
  Update usage of TABLE->alias
sql/ha_partition.cc:
  Update usage of TABLE->alias
sql/handler.cc:
  Update usage of TABLE->alias
  Fixed wrong usage of str.ptr()
sql/item.cc:
  Fixed error where code wrongly assumed string was \0 terminated.
sql/item_func.cc:
  c_ptr() -> c_ptr_safe()
  Update usage of TABLE->alias
sql/item_sum.h:
  Use my_strtod() instead of my_atof() to avoid having to add \0 to string
sql/lock.cc:
  Update usage of TABLE->alias
sql/log.cc:
  c_ptr() -> ptr() as \0 was not needed
sql/log_event.cc:
  c_ptr_quick() -> ptr() as \0 was not needed
sql/opt_range.cc:
  ptr() -> c_ptr() as \0 is needed
sql/opt_subselect.cc:
  Update usage of TABLE->alias
sql/opt_table_elimination.cc:
  Update usage of TABLE->alias
sql/set_var.cc:
  ptr() -> c_ptr() as \0 is needed
  c_ptr() -> c_ptr_safe()
sql/sp.cc:
  c_ptr() -> ptr() as \0 was not needed
sql/sp_rcontext.cc:
  
  Update usage of TABLE->alias
sql/sql_base.cc:
  Preallocate buffers
  Update usage of TABLE->alias
sql/sql_class.cc:
  Fix arguments to sprintf() to work even if string is not \0 terminated
sql/sql_insert.cc:
  Update usage of TABLE->alias
  c_ptr() -> ptr() as \0 was not needed
sql/sql_load.cc:
  Preallocate buffers
  Trivial optimizations
sql/sql_parse.cc:
  Trivial optimization
sql/sql_plugin.cc:
  c_ptr() -> ptr() as \0 was not needed
sql/sql_select.cc:
  Update usage of TABLE->alias
sql/sql_show.cc:
  Update usage of TABLE->alias
sql/sql_string.h:
  Added move() function to move allocated memory from one object to another.
sql/sql_table.cc:
  Update usage of TABLE->alias
  c_ptr() -> c_ptr_safe()
sql/sql_test.cc:
  ptr() -> c_ptr_safe()
sql/sql_trigger.cc:
  Update usage of TABLE->alias
  c_ptr() -> c_ptr_safe()
sql/sql_update.cc:
  Update usage of TABLE->alias
sql/sql_view.cc:
  ptr() -> c_ptr_safe()
sql/sql_yacc.yy:
  ptr() -> c_ptr()
sql/table.cc:
  
  Update usage of TABLE->alias
sql/table.h:
  Changed TABLE->alias to String to get fewer reallocs when alias are used.
storage/federatedx/ha_federatedx.cc:
  Use c_ptr_safe() to ensure strings are \0 terminated.
storage/maria/ha_maria.cc:
  Update usage of TABLE->alias
storage/myisam/ha_myisam.cc:
  Update usage of TABLE->alias
storage/xtradb/row/row0sel.c:
  Ensure that null bits in record are properly reset.
  (Old code didn't work as row_search_for_mysql() can be called twice while reading fields from one row.
2010-11-24 00:08:48 +02:00
Michael Widenius
b52020221e Merge with MySQL 5.1.52 2010-11-23 23:39:59 +02:00
Michael Widenius
0543e2e34e Merge to get make String reallocation faster 2010-11-16 19:52:44 +02:00
Michael Widenius
7b047a31a0 Make SQLString reallocation addaptive
Avoid doing reallocs
Prealloc some strings / provide extension allocation size to some strings
This gave a 25 % speedup in some mysql-test-run tests.



mysys/safemalloc.c:
  More DBUG_PRINT
sql/net_serv.cc:
  Make all mallocs() look the similar. (just-for-safety fix)
sql/protocol.cc:
  Ensure that communication packet buffer is allocated.
  (It's freed by stored precedures and some DLL statements)
sql/sp.cc:
  Fixed valgrind warning
sql/sql_select.cc:
  Set extent allocation for buffer that has a lot of append() calls.
sql/sql_show.cc:
  Fixed wrong usage of string buffer. Old code worked in test suite 'just-by-chance'
sql/sql_string.cc:
  Call realloc_with_extra_if_needed() in append() functions.
sql/sql_string.h:
  Added 'extra_alloc' member, to specify chunck size for realloc().
  extra_alloc is addaptive to catch cases where preallocation of buffers is not done properly.
  Simplified free() to allow compiler to optimize things better (and to keep things consistent).
  Fixed shrink() to take into account the extra memory added to the Alloced_length in realloc(). This saves us a realloc() per query.
sql/sql_test.cc:
  Set extent allocation for buffer that has a lot of append() calls.
sql/table.cc:
  Set extent allocation for buffer that has a lot of append() calls.
2010-11-08 13:43:54 +02:00
Sergei Golubchik
74711a4615 merge w/ 5.2 2010-11-02 10:12:29 +01:00
Sergei Golubchik
5789f96c62 fix LIKE in a vcol function, broken by a fix for mysql bug#54568.
don't set view_prepare_mode when opening a base table
(either in SHOW CREATE or in I_S.TABLES)
2010-10-30 19:54:38 +02:00
Sergey Petrunya
72dd7575cd Merge 5.2->5.3
- Re-commit Monty's merge, partially fixed by Igor and SergeyP, 
  but still broken
2010-10-10 17:18:11 +03:00
Mattias Jonsson
814fbc5b6f Bug#51851: Server with SBR locks mutex twice on
LOAD DATA into partitioned MyISAM table

Problem was that both partitioning and myisam
used the same table_share->mutex for different protections
(auto inc and repair).

Solved by adding a specific mutex for the partitioning
auto_increment.

Also adding destroying the ha_data structure in
free_table_share (which is to be propagated
into 5.5).

This is a 5.1 ONLY patch, already fixed in 5.5+.
2010-10-01 13:39:04 +02:00
Sergei Golubchik
a3d80d952d merge with 5.1 2010-09-11 20:43:48 +02:00
unknown
11dc256ca4 2010-09-08 09:26:17 +03:00
Michael Widenius
9f85560212 Enable archive tables to work with mysql_upgrade / repair
Made long file names from previous patch shorter

mysql-test/r/archive.result:
  Added testing of repair (for upgrade) of 5.0 tables.
mysql-test/std_data/archive_5_0.ARM:
  Archive table created in MySQL 5.0
mysql-test/std_data/archive_5_0.ARZ:
  Archive table created in MySQL 5.0
mysql-test/std_data/archive_5_0.frm:
  Archive table created in MySQL 5.0
mysql-test/std_data/long_table_name.MYD:
  Made long file names shorter
mysql-test/std_data/long_table_name.MYI:
  Made long file names shorter
mysql-test/std_data/long_table_name.frm:
  Made long file names shorter
mysql-test/t/archive.test:
  Added testing of repair (for upgrade) of 5.0 tables.
sql/sql_table.cc:
  Allow recreate to open crashed tables.
sql/table.cc:
  Fix error message if storage engine doesn't exists.
storage/archive/azio.c:
  Reset status values in case archive is of old versions
storage/archive/ha_archive.cc:
  Fix to allow one to open old versions of table during repair
  Reset status variables for old version tables
  If the the table is of old version, force upgrade with ALTER TABLE when doing repair
storage/archive/ha_archive.h:
  Added variables to detect old versions
2010-09-03 20:55:56 +03:00
Michael Widenius
a4fff491eb Fix that one can run mysql_upgrade with long table names
Fall back to use ALTER TABLE for engines that doesn't support REPAIR when doing repair for upgrade.
Nicer output from mysql_upgrade and mysql_check
Updated all arrays that used NAME_LEN to use SAFE_NAME_LEN to ensure that we don't break things accidently as names can now have a #mysql50# prefix.

client/mysql_upgrade.c:
  If we are using verbose, also run mysqlcheck in verbose mode.
client/mysqlcheck.c:
  Add more information if running in verbose mode
  Print 'Needs upgrade' instead of complex error if table needs to be upgraded
  Don't write connect information if verbose is not 2 or above
mysql-test/r/drop.result:
  Updated test and results as we now support full table names
mysql-test/r/grant.result:
  Now you get a correct error message if using #mysql with paths
mysql-test/r/show_check.result:
  Update results as table names can temporarly be bigger than NAME_LEN (during upgrade)
mysql-test/r/upgrade.result:
  Test upgrade for long table names.
mysql-test/suite/funcs_1/r/is_tables_is.result:
  Updated old test result (had note been updated in a while)
mysql-test/t/drop.test:
  Updated test and results as we now support full table names
mysql-test/t/grant.test:
  Now you get a correct error message if using #mysql with paths
mysql-test/t/upgrade.test:
  Test upgrade for long table names.
sql/ha_partition.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/item.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/log_event.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/mysql_priv.h:
  Added SAFE_NAME_LEN
sql/rpl_filter.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sp.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sp_head.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_acl.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_base.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_connect.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_parse.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_prepare.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_select.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_show.cc:
  NAME_LEN -> SAFE_NAME_LEN
  Enlarge table names for SHOW TABLES to also include optional #mysql50#
sql/sql_table.cc:
  Fall back to use ALTER TABLE for engines that doesn't support REPAIR when doing repair for upgrade.
sql/sql_trigger.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_udf.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/sql_view.cc:
  NAME_LEN -> SAFE_NAME_LEN
sql/table.cc:
  Fixed check_table_name() to not count #mysql50# as part of name
  If #mysql50# is part of the name, don't allow path characters in name.
2010-09-03 19:20:30 +03:00
Michael Widenius
13141c9842 Fixed compiler warnings and test failures 2010-08-06 11:05:44 +03:00
Michael Widenius
d042146e5b Merge with MariaDB 5.1.49
Removed references to HA_END_SPACE_KEY (which has been 0 for a long time)
2010-08-05 22:56:11 +03:00
Michael Widenius
1f5b93e772 Fixed compiler warnings
Fixed some wrong test cases
Fixed bug in null handling in XtraDB


extra/comp_err.c:
  Fixed compiler warnings
extra/my_print_defaults.c:
  Fixed compiler warnings
mysql-test/suite/binlog/t/binlog_killed.test:
  Added support for timeouts
mysql-test/suite/funcs_1/r/is_columns_is.result:
  Updated results (INNODB_SYS_TABLES had got new column)
scripts/mysql_install_db.sh:
  Fixed typo
sql/mysql_priv.h:
  Removed not needed argument for compare_record()
sql/sql_insert.cc:
  Removed not needed argument for compare_record()
sql/sql_update.cc:
  Removed not needed argument for compare_record()
  The argument is not needed becasue we copy the full record[0] to record[1] and the comparison should work even if all columns are not read
sql/table.cc:
  The comparison of rows is independent of HA_PARTIAL_COLUMN_READ
storage/maria/maria_chk.c:
  Fixed compiler warnings
storage/maria/maria_read_log.c:
  Fixed compiler warnings
storage/myisam/myisamchk.c:
  Fixed compiler warnings
storage/myisam/myisampack.c:
  Fixed compiler warnings
storage/xtradb/dict/dict0load.c:
  Fixed compiler warnings
storage/xtradb/row/row0sel.c:
  Fixed null handling in XtraDB. (See comment)
storage/xtradb/trx/trx0sys.c:
  Fixed compiler warnings
support-files/compiler_warnings.supp:
  Fixed compiler warnings
2010-08-04 21:36:11 +03:00
Michael Widenius
cd9706b27e Fixes bug when we run bcmp() on row when the storage engine hasn't filled in all fields in the row.
This was triggered by innodb.innodb_multi_update, where we had a static length row without nulls and xtradb didn't fill in the delete-marker byte


include/my_bitmap.h:
  Added prototype for bitmap_union_is_set_all()
mysys/my_bitmap.c:
  Added function to check if union of two bit maps covers all bits.
sql/mysql_priv.h:
  Updated protype for compare_record()
sql/sql_insert.cc:
  Send to compare_record() flag if all fields are used.
sql/sql_select.cc:
  Set share->null_bytes_for_compare.
sql/sql_update.cc:
  In compare_record() don't use the fast cmp_record() (which is basically memcmp) if we don't know that all fields exists.
  Don't compare the null_bytes if there is no data there.
sql/table.cc:
  Store in share->null_bytes_for_compare the number of bytes that has null or bit fields (but not delete marker)
  Store in can_cmp_whole_record if we can use memcmp() (assuming all rows are read) to compare rows in compare_record()
sql/table.h:
  Added two elements in table->share to speed up checking how updated rows can be compared.
2010-08-04 16:01:13 +03:00
Michael Widenius
e0a6b02c5d Merge with MySQL 5.1.49
Fixed Bug#52005 'JOIN_TAB->dependent' may be incorrectly propageted for multilevel outer joins' in a better way (patch from Sergey Petrunya)
2010-08-02 12:01:24 +03:00
Davi Arnaut
9a5fa17fd3 Bug#45288: pb2 returns a lot of compilation warnings on linux
Fix warnings flagged by the new warning option -Wunused-but-set-variable
that was added to GCC 4.6 and that is enabled by -Wunused and -Wall. The
option causes a warning whenever a local variable is assigned to but is
later unused. It also warns about meaningless pointer dereferences.

client/mysql.cc:
  Meaningless pointer dereferences.
client/mysql_upgrade.c:
  Check whether reading from the file succeeded.
extra/comp_err.c:
  Unused.
extra/yassl/src/yassl_imp.cpp:
  Skip instead of reading data that is discarded.
include/my_pthread.h:
  Variable is only used in debug builds.
include/mysys_err.h:
  Add new error messages.
mysys/errors.c:
  Add new error message for permission related functions.
mysys/mf_iocache.c:
  Variable is only checked under THREAD.
mysys/my_copy.c:
  Raise a error if chmod or chown fails.
mysys/my_redel.c:
  Raise a error if chmod or chown fails.
regex/engine.c:
  Use a equivalent variable for the assert.
server-tools/instance-manager/instance_options.cc:
  Unused.
sql/field.cc:
  Unused.
sql/item.cc:
  Unused.
sql/log.cc:
  Do not ignore the return value of freopen: only set buffer if
  reopening succeeds.
  
  Adjust doxygen comment to the right function.
  
  Pass message lenght to log function.
sql/mysqld.cc:
  Do not ignore the return value of freopen: only set buffer if
  reopening succeeds.
sql/partition_info.cc:
  Unused.
sql/slave.cc:
  No need to set pointer to the address of '\0'.
sql/spatial.cc:
  Unused. Left for historical purposes.
sql/sql_acl.cc:
  Unused.
sql/sql_base.cc:
  Pointers are always set to the same variables.
sql/sql_parse.cc:
  End statement if reading fails.
  
  Store the buffer after it has actually been updated.
sql/sql_repl.cc:
  No need to set pointer to the address of '\0'.
sql/sql_show.cc:
  Put variable under the same ifdef block.
sql/udf_example.c:
  Set null pointer flag appropriately.
storage/csv/ha_tina.cc:
  Meaningless dereferences.
storage/example/ha_example.cc:
  Return the error since it's available.
storage/myisam/mi_locking.c:
  Remove unused and dead code.
2010-07-20 15:07:36 -03:00
Igor Babaev
f78b870c9b Fixed bug #607566.
For queries with order by clauses that employed filesort usage of
virtual column references in select lists could trigger assertion
failures. It happened because a wrong vcol_set bitmap was used for
filesort. It turned out that filesort required its own vcol_set bitmap.

Made management of the vcol_set bitmaps similar to the management
of the read_set and write_set bitmaps.
2010-07-19 22:41:24 -07:00
Igor Babaev
4f564a5443 Merge 2010-07-17 12:58:08 -07:00
Igor Babaev
452860dfde Fixed bug #604503.
If the expression for a virtual column of table contained datetime
comparison then the execution of the second query that used this
virtual column caused a crash. It happened because the execution
of the first query that used this virtual column inserted a cached
item into the expression tree. The cached tree was allocated in
the statement memory while the expression tree was allocated in
the table memory.
Now the cached items that are inserted into expressions for virtual
columns with datetime comparisons are always allocated in the same
mem_root as the expressions for virtual columns. So now the inserted
cached items are valid for any queries that use these virtual columns.
2010-07-17 11:16:16 -07:00
Igor Babaev
4090100743 Fixed bug #603186.
There were two problems that caused wrong results reported with this bug.
1. In some cases stored(persistent) virtual columns were not marked
in the write_set and in the vcol_set bitmaps.
2. If the list of fields in an insert command was empty then the values of
the stored virtual columns were set to default.

To fix the first problem the function st_table::mark_virtual_columns_for_write
was modified. Now the function has a parameter that says whether the virtual 
columns are to be marked for insert or for update.  
To fix the second problem a special handling of empty insert lists is
added in the function fill_record().
2010-07-15 16:51:05 -07:00
Igor Babaev
73be27c07f Fixed bug #604549.
There was no error thrown when creating a table with a virtual table
computed by an expression returning a row.
This caused a crash when inserting into the table.

Removed periods at the end of the error messages for virtual columns.
Adjusted output in test result files accordingly.
2010-07-13 07:34:14 -07:00
unknown
ceb5468fd8 Subquery cache (MWL#66) added.
libmysqld/Makefile.am:
  The new file added.
mysql-test/r/index_merge_myisam.result:
  subquery_cache optimization option added.
mysql-test/r/myisam_mrr.result:
  subquery_cache optimization option added.
mysql-test/r/subquery_cache.result:
  The subquery cache tests added.
mysql-test/r/subselect3.result:
  Subquery cache switched off to avoid changing read statistics.
mysql-test/r/subselect3_jcl6.result:
  Subquery cache switched off to avoid changing read statistics.
mysql-test/r/subselect_no_mat.result:
  subquery_cache optimization option added.
mysql-test/r/subselect_no_opts.result:
  subquery_cache optimization option added.
mysql-test/r/subselect_no_semijoin.result:
  subquery_cache optimization option added.
mysql-test/r/subselect_sj.result:
  subquery_cache optimization option added.
mysql-test/r/subselect_sj_jcl6.result:
  subquery_cache optimization option added.
mysql-test/t/subquery_cache.test:
  The subquery cache tests added.
mysql-test/t/subselect3.test:
  Subquery cache switched off to avoid changing read statistics.
sql/CMakeLists.txt:
  The new file added.
sql/Makefile.am:
  The new files added.
sql/item.cc:
  Expression cache item (Item_cache_wrapper) added.
  Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP.
sql/item.h:
  Expression cache item (Item_cache_wrapper) added.
  Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP.
sql/item_cmpfunc.cc:
  Subquery cache added.
sql/item_cmpfunc.h:
  Subquery cache added.
sql/item_subselect.cc:
  Subquery cache added.
sql/item_subselect.h:
  Subquery cache added.
sql/item_sum.cc:
  Registration of subquery parameters added.
sql/mysql_priv.h:
  subquery_cache optimization option added.
sql/mysqld.cc:
  subquery_cache optimization option added.
sql/opt_range.cc:
  Fix due to subquery cache.
sql/opt_subselect.cc:
  Parameters of the function cahnged.
sql/procedure.h:
  .h file guard added.
sql/sql_base.cc:
  Registration of subquery parameters added.
sql/sql_class.cc:
  Option to allow add indeces to temporary table.
sql/sql_class.h:
  Item iterators added.
  Option to allow add indeces to temporary table.
sql/sql_expression_cache.cc:
  Expression cache for caching subqueries added.
sql/sql_expression_cache.h:
  Expression cache for caching subqueries added.
sql/sql_lex.cc:
  Registration of subquery parameters added.
sql/sql_lex.h:
  Registration of subqueries and subquery parameters added.
sql/sql_select.cc:
  Subquery cache added.
sql/sql_select.h:
  Subquery cache added.
sql/sql_union.cc:
  A new parameter to the function added.
sql/sql_update.cc:
  A new parameter to the function added.
sql/table.cc:
  Procedures to manage temporarty tables index added.
sql/table.h:
  Procedures to manage temporarty tables index added.
storage/maria/ha_maria.cc:
  Fix of handler to allow destoy a table in case of error during the table creation.
storage/maria/ha_maria.h:
  .h file guard added.
storage/myisam/ha_myisam.cc:
  Fix of handler to allow destoy a table in case of error during the table creation.
2010-07-10 13:37:30 +03:00
Sergey Petrunya
27f9fc063c MariaDB 5.2 -> MariaDB 5.3 merge 2010-06-26 14:05:41 +04:00
Davi Arnaut
6f3a540c37 Bug#42733: Type-punning warnings when compiling MySQL --
strict aliasing violations.

Essentially, the problem is that large parts of the server were
developed in simpler times (last decades, pre C99 standard) when
strict aliasing and compilers supporting such optimizations were
rare to non-existent. Thus, when compiling the server with a modern
compiler that uses strict aliasing rules to perform optimizations,
there are several places in the code that might trigger undefined
behavior.

As evinced by some recent bugs, GCC does a somewhat good of job
misoptimizing such code, but on the other hand also gives warnings
about suspicious code. One problem is that the warnings aren't
always accurate, yet we can't afford to just shut them off as we
might miss real cases. False-positive cases are aggravated mostly
by casts that are likely to trigger undefined behavior.

The solution is to start a cleanup process focused on fixing and
reducing the amount of strict-aliasing related warnings produced
by GCC and others compilers. A good deal of noise reduction can
be achieved by just removing useless casts that are product of
historical cruft and are likely to trigger undefined behavior if
dereferenced.

client/mysql.cc:
  Remove now-unnecessary casts.
  Break up large strings.
client/mysql_upgrade.c:
  Remove now-unnecessary casts.
client/mysqladmin.cc:
  Remove now-unnecessary casts.
  Break up large strings.
client/mysqlbinlog.cc:
  Remove now-unnecessary casts.
client/mysqlcheck.c:
  Remove now-unnecessary casts.
client/mysqldump.c:
  Remove now-unnecessary casts.
client/mysqlimport.c:
  Remove now-unnecessary casts.
client/mysqlshow.c:
  Remove now-unnecessary casts.
client/mysqlslap.c:
  Remove now-unnecessary casts.
client/mysqltest.cc:
  Remove now-unnecessary casts.
extra/comp_err.c:
  Remove now-unnecessary casts.
extra/my_print_defaults.c:
  Remove now-unnecessary casts.
  Break up large strings.
extra/mysql_waitpid.c:
  Remove now-unnecessary casts.
extra/perror.c:
  Remove now-unnecessary casts.
extra/resolve_stack_dump.c:
  Remove now-unnecessary casts.
extra/resolveip.c:
  Remove now-unnecessary casts.
include/my_getopt.h:
  Use a void pointer type as the opaque type to avoid problems with type
  incompatibility -- GCC issues warnings when the type name is not type
  compatible with a operand. As a side bonus, a explicit cast won't be
  necessary anymore.
include/sslopt-longopts.h:
  Remove now-unnecessary casts.
  Break up large strings.
mysys/my_getopt.c:
  Update opaque type and introduce a type definition for the
  argument to my_getopt_register_get_addr.
server-tools/instance-manager/options.cc:
  Remove now-unnecessary casts.
sql/mysqld.cc:
  Remove now-unnecessary casts.
  Break up large strings.
  Update mysql_getopt_value prototype (the old prototype
  was different from the definition anyway).
sql/sql_plugin.cc:
  The type of a pointer to a function must be compatible with the
  pointed-to function type, otherwise the behavior is undefined.
sql/table.cc:
  The variable buf pointer to pointer to pointer to constant char
  could improperly alias a incompatible type in call to fix_type_
  pointers. Since this was actually dead code, it is simply removed.
sql/unireg.cc:
  Remove call to get_form_pos. The code creates a new FRM file which
  is always truncated and writes the form position as 0. Hence, no
  need to retrieve it, we now for sure it is 0.
storage/archive/archive_reader.c:
  Remove now-unnecessary casts.
storage/myisam/ft_nlq_search.c:
  Read weight directly from the buffer.
storage/myisam/fulltext.h:
  Add explanation about the type duality of a key buffer.
  Add accessor macro to retrieve a FT float value.
storage/myisam/mi_test1.c:
  Remove now-unnecessary casts.
storage/myisam/myisam_ftdump.c:
  Read weight directly from the buffer.
storage/myisam/myisamchk.c:
  Remove now-unnecessary casts.
storage/myisam/myisamlog.c:
  A pointer to char was used to alias a pointer to pointer to
  unsigned char, thus violating strict aliasing rules.
storage/myisam/myisampack.c:
  Remove now-unnecessary casts.
strings/decimal.c:
  Remove aliasing violation, printing the value is enough for
  debugging purposes.
tests/mysql_client_test.c:
  Remove now-unnecessary casts.
2010-06-10 17:16:43 -03:00
Sergei Golubchik
ac6b3c4430 few small MySQL bugs/issues that impact the engines, as discussed in the SE summit
* remove handler::index_read_last()
* create handler::keyread_read_time() (was get_index_only_read_time() in opt_range.cc)
* ha_show_status() allows engine's show_status() to fail
* remove HTON_FLUSH_AFTER_RENAME
* fix key_cmp_if_same() to work for floats and doubles
* set table->status in the server, don't force engines to do it
* increment status vars in the server, don't force engines to do it

mysql-test/r/status_user.result:
  correct test results - innodb was wrongly counting internal
  index searches as handler_read_* calls.
sql/ha_partition.cc:
  compensate for handler incrementing status counters -
  we want to count only calls to underlying engines
sql/handler.h:
  inline methods moved to sql_class.h
sql/key.cc:
  simplify the check
sql/opt_range.cc:
  move get_index_only_read_time to the handler class
sql/sp.cc:
  don't use a key that's stored in the record buffer -
  the engine can overwrite the buffer with anything, destroying the key
sql/sql_class.h:
  inline handler methods that need to see THD and TABLE definitions
sql/sql_select.cc:
  no ha_index_read_last_map anymore
sql/sql_table.cc:
  remove HTON_FLUSH_AFTER_RENAME
sql/table.cc:
  set HA_CAN_MEMCMP as appropriate
sql/tztime.cc:
  don't use a key that's stored in the record buffer -
  the engine can overwrite the buffer with anything, destroying the key
storage/myisam/ha_myisam.cc:
  engines don't need to update table->status or use ha_statistic_increment anymore
storage/myisam/ha_myisam.h:
  index_read_last_map is no more
2010-06-05 16:53:36 +02:00
Sergei Golubchik
a0a81bd251 fixes for test suite
mysql-test/suite/pbxt/r/mysqlshow.result:
  update the forgotten test results
sql/table.cc:
  add defensive asserts.
  fix the code that didn't in MySQL > 5.2.0 with frm's created before 5.1.10
2010-06-03 11:28:36 +02:00
Sergei Golubchik
ffc8f62b08 merge 5.1->5.2 2010-06-01 21:52:20 +02:00
Michael Widenius
4aa9d903c1 Merge with MySQL 5.1.47
Fixed some bugs introduced in 5.1.47
Disabled some tests until we have merged with latest Xtradb

configure.in:
  Added testing if valgrind/memcheck.h exists
storage/pbxt/src/ha_pbxt.cc:
  LOCK_plugin is not anymore locked in init
2010-05-26 21:55:40 +03:00
Alexey Kopytov
1d0acc7754 Bug #53830: !table || (!table->read_set ||
bitmap_is_set(table->read_set, field_index))

UPDATE on an InnoDB table modifying the same index that is used
to satisfy the WHERE condition could trigger a debug assertion
under some circumstances.

Since for engines with the HA_PRIMARY_KEY_IN_READ_INDEX flag
set results of an index scan on a secondary index are appended
by the primary key value, if a query involves only columns from
the primary key and a secondary index, the latter is considered
to be covering.

That tricks mysql_update() to mark for reading only columns
from the secondary index when it does an index scan to retrieve
rows to update in case a part of that key is also being
updated. However, there may be other columns in WHERE that are
part of the primary key, but not the secondary one.

What we actually want to do in this case is to add index
columns to the existing WHERE columns bitmap rather than
replace it.

mysql-test/r/innodb_mysql.result:
  Test case for bug #53830.
mysql-test/t/innodb_mysql.test:
  Test case for bug #53830.
sql/sql_update.cc:
  Add index columns to the read_set bitmap, don't replace it.
sql/table.cc:
  Added a new add_read_columns_used_by_index() function to 
  st_table.
sql/table.h:
  Added a new add_read_columns_used_by_index() function to 
  st_table.
2010-05-25 18:43:45 +04:00
Gleb Shchepa
d72a4710aa Bug #53804: serious flaws in the alter database .. upgrade
data directory name command

The check_db_name function has been modified to validate tails of
#mysql50#-prefixed database names for compliance with MySQL 5.0
database name encoding rules (the check_table_name function call
has been reused).


mysql-test/r/renamedb.result:
  Updated test case.
mysql-test/r/upgrade.result:
  Test case for bug #53804.
mysql-test/t/renamedb.test:
  Updated test case.
mysql-test/t/upgrade.test:
  Test case for bug #53804.
sql/mysql_priv.h:
  Bug #53804: serious flaws in the alter database .. upgrade
              data directory name command
  
  The check_mysql50_prefix has been added.
sql/sql_table.cc:
  Bug #53804: serious flaws in the alter database .. upgrade
              data directory name command
  
  - The check_mysql50_prefix has been added.
  - The check_n_cut_mysql50_prefix function has been refactored
  to share code with new check_mysql50_prefix function.
sql/table.cc:
  Bug #53804: serious flaws in the alter database .. upgrade
              data directory name command
  
  The check_db_name function has been modified to validate tails of
  #mysql50#-prefixed database names for compliance with MySQL 5.0
  database name encoding rules.
2010-05-21 22:47:32 +04:00
Sergei Golubchik
38b3218c4d merged 2010-05-15 14:44:06 +02:00
Michael Widenius
6659ad49fe Fixes after last merge of MySQL 5.1
- INSERT with RAND() doesn't require row based logging again
- Some bugs fixed in opt_range() where we table->key_read was wrongly used



.bzrignore:
  Ignore new xtstat binary
mysql-test/r/index_merge_myisam.result:
  Update results (old result was wrong)
mysql-test/suite/binlog/r/binlog_stm_binlog.result:
  Added drop table first
mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result:
  Added test for when RAND() requires row based logging
mysql-test/suite/binlog/t/binlog_stm_binlog.test:
  Added drop table first
mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test:
  Added test for when RAND() requires row based logging
scripts/make_binary_distribution.sh:
  Removed type from last commit
sql/item_create.cc:
  Don't require row based logging when using RAND() with INSERT
sql/opt_range.cc:
  Revert wrong patch from Oracle:
  - As QUICK_RANGE_SELECT uses it's own 'file' handler to the tables, one can't use 'table->key_read' as a flag to detect if index only read (keyread) is used or not
  - Don't set keyread if keyread is already enabled
  - Don't disable key read, if we didn't enable it ourselves
  - Simplify code (and ensure that we do proper cleanup of index only read)
sql/opt_range.h:
  Added flags to detect if the range optimizer enabled index only read (key read) or not
sql/opt_sum.cc:
  Use our more optimized macros
sql/sql_lex.h:
  Added 'readable' function to check if we are in a sub query function or not (not normal query or sub query in FROM clause)
sql/sql_select.cc:
  Use our more optimized keyread macros
  Added ASSERTS early
  Simplify code on eliminate_item_equal()
  Fixed that substitute_for_best_equal_field() doesn't core dump in case of out of memory conditions.
  Removed not needed test for 'field->maybe_null()'
  Replaced master_unit()->item with is_subquery_function() (More readable)
sql/sql_update.cc:
  Use our more optimized keyread macros
sql/table.cc:
  Use our more optimized keyread macros
sql/table.h:
  Use separate functions to enable/disable Index only reads
  - Safer, more readable, better logging and faster.
2010-05-13 14:00:53 +03:00