Commit graph

557 commits

Author SHA1 Message Date
Joerg Bruehe
5be07ceadd Merge 5.5.24 back into main 5.5.
This is a weave merge, but without any conflicts.
In 14 source files, the copyright year needed to be updated to 2012.
2012-05-07 22:20:42 +02:00
Tor Didriksen
83d455be90 Bug#13871079 RQG_MYISAM_DML_ALTER_VALGRIND FAILS ON VALGRIND PN PB2
The class Copy_field contains a String tmp, 
which may allocate memory on the heap.
That means that all instances of Copy_field
must be properly destroyed. Alas they are not.

Solution: don't use Copy_field::tmp for copying
from_field => tmp => to_field
in do_field_string()


sql/field.cc:
  In Field_set::val_str
  return empty string (of appropriate character set) for an empty set.
sql/field.h:
  New private member in Field_enum: empty_set_string.
sql/field_conv.cc:
  In do_field_string, use an auto variable for copying
  from_field => tmp => to_field
  rather than copy->tmp.
2012-04-12 15:04:22 +02:00
Jorgen Loland
aea2e93bd8 Merge BUG#12997905 from 5.1 to 5.5 2011-11-18 14:53:54 +01:00
Jorgen Loland
523c849d14 Backmerge of BUG#12997905 2011-11-18 14:47:11 +01:00
Kent Boortz
027b5f1ed4 Updated/added copyright headers 2011-07-03 17:47:37 +02:00
Kent Boortz
68f00a5686 Updated/added copyright headers 2011-06-30 17:37:13 +02:00
Kent Boortz
44135d4725 Updated/added copyright headers 2011-06-30 17:31:31 +02:00
Tor Didriksen
7779c79f04 Bug#11908153: CRASH AND/OR VALGRIND ERRORS IN FIELD_BLOB::GET_KEY_IMAGE
Field_geom::reset() failed to reset its base Field_blob. 
The range optimizer used the un-initilized field during optimization and execution.

mysql-test/r/gis.result:
  New test case.
mysql-test/t/gis.test:
  New test case.
sql/field.h:
  Field_geom::reset() must call Field_blob::reset(), even if the field is not nullable.
2011-07-04 13:53:07 +02:00
Kent Boortz
02e07e3b51 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Magne Mahre
9ff72a1acf Bug#11900714 REMOVE LGPL LICENSED FILES IN MYSQL 5.1
The LGPL license is used in some legacy code, and to
adhere to current licensing polity, we remove those
files that are no longer used, and reorganize the
remaining LGPL code so it will be GPL licensed from
now on.
      
Note:  This patch only removed LGPL licensed files
       in MySQL 5.1, and is the second of a set of
       patches to remove LGPL from all trees.
       (See Bug# 11840513 for details)
2011-03-28 10:47:30 +02:00
Alexander Barkov
ba68b26ae9 Bug#58190 BETWEEN no longer uses indexes for date or datetime fields
Regression introduced by WL#2649.

Problem: queries with date/datetime columns did not use indexes:
set names non_latin1_charset;
select * from date_index_test
where date_column between '2010-09-01' and '2010-10-01';

before WL#2649 indexes worked fine because charset of 
date/datetime
columns was BINARY which always won.

Fix: testing that collation of the operation matches collation 
of the field is only needed in case of "real" string data types.
For DATE, DATETIME it's not needed.


  @ mysql-test/include/ctype_numconv.inc
  @ mysql-test/r/ctype_binary.result
  @ mysql-test/r/ctype_cp1251.result
  @ mysql-test/r/ctype_latin1.result
  @ mysql-test/r/ctype_ucs.result
  @ mysql-test/r/ctype_utf8.result
  Adding tests

  @ sql/field.h
  Adding new method Field_str::match_collation_to_optimize_range()
  for use in opt_range.cc to distinguish between
  "real string" types like CHAR, VARCHAR, TEXT
  (Field_string, Field_varstring, Field_blob)

  and "almost string" types DATE, TIME, DATETIME
  (Field_newdate, Field_datetime, Field_time, Field_timestamp)

  @ sql/opt_range.cc
  Using new method instead of checking result_type() against STRING result.

Note:

  Another part of this problem (which is not regression) 
  is submitted separately (see bug##58329).
2010-11-19 20:15:47 +03:00
Mats Kindahl
8642812c98 Bug #52131: SET and ENUM stored endian-dependent in binary log
Replication SET and ENUM fields from a big-endian to a little-
endian machine (or the opposite) that are represented using
more than 1 byte (SET fields with more than 8 members or ENUM
fields with more than 256 constants) will fail to replicate
correctly when using row-based replication.

The reason is that there are no pack() or unpack() functions
for Field_set or Field_enum, which make them rely on Field::pack
and Field::unpack. These functions pack data as strings, but
since Field_set and Field_enum use integral types for
representation, the fields are stored incorrectly on big-endian
machines.

This patch adds Field_enum::pack and Field_enum::unpack
functions that store the integral value correctly in the binary
log even on big-endian machines. Since Field_set inherits from
Field_enum, it will use the same functions for packing and
unpacking the field.

sql/field.cc:
  Removing some obsolete debug printouts and adding Field_enum::pack
  and Field_enum::unpack functions.
sql/field.h:
  Adding helper functions for packing and unpacking 16- and
  24-bit integral types.
  
  Field_short::pack and Field_short::unpack now use these functions.
sql/rpl_record.cc:
  Removing some obsolete debug printouts and adding some
  more useful ones.
2010-10-06 19:20:18 +02:00
Davi Arnaut
e001970cc7 WL#5498: Remove dead and unused source code
Remove workarounds for ancient systems.

mysys/default.c:
  Make cast more explicit to ensure a correct offset.
2010-07-23 17:17:55 -03:00
Davi Arnaut
bc4ba28cab WL#5498: Remove dead and unused source code
Remove unused variables.
2010-07-23 17:13:36 -03:00
Alexander Barkov
eed26e92a6 Bug#52520 Difference in tinytext utf column metadata
Problems:
      - regression (compating to version 5.1) in metadata for BLOB types
      - inconsistency between length metadata in server and embedded for BLOB types
      - wrong max_length calculation in items derived from BLOB columns
     @ libmysqld/lib_sql.cc
        Calculating length metadata in embedded similary to server version,
        using new function char_to_byte_length_safe().
     @ mysql-test/r/ctype_utf16.result
        Adding tests
     @ mysql-test/r/ctype_utf32.result
        Adding tests
     @ mysql-test/r/ctype_utf8.result
        Adding tests
     @ mysql-test/r/ctype_utf8mb4.result
        Adding tests
     @ mysql-test/t/ctype_utf16.test
        Adding tests
     @ mysql-test/t/ctype_utf32.test
        Adding tests
     @ mysql-test/t/ctype_utf8.test
        Adding tests
     @ mysql-test/t/ctype_utf8mb4.test
        Adding tests
     @ sql/field.cc
        Overriding char_length() for Field_blob:
        unlike in generic Item::char_length() we don't
        divide to mbmaxlen for BLOBs.
     @ sql/field.h
        - Making Field::char_length() virtual
        - Adding prototype for Field_blob::char_length()
     @ sql/item.h
        - Adding new helper function char_to_byte_length_safe()
        - Using new function
     @ sql/protocol.cc
        Using new function char_to_byte_length_safe().

    modified:
      libmysqld/lib_sql.cc
      mysql-test/r/ctype_utf16.result
      mysql-test/r/ctype_utf32.result
      mysql-test/r/ctype_utf8.result
      mysql-test/r/ctype_utf8mb4.result
      mysql-test/t/ctype_utf16.test
      mysql-test/t/ctype_utf32.test
      mysql-test/t/ctype_utf8.test
      mysql-test/t/ctype_utf8mb4.test
      sql/field.cc
      sql/field.h
      sql/item.h
      sql/protocol.cc
2010-06-02 16:23:50 +04:00
Alexey Kopytov
fa3b2dcb83 Manual merge of mysql-5.1-bugteam to
mysql-trunk-merge.

Conflicts:

Text conflict in sql/sql_priv.h
2010-04-19 16:09:44 +04:00
Alexey Kopytov
199f2ce47e Some post-merge fixes afer a merge from mysql-5.1-bugteam. 2010-04-11 14:42:05 +04:00
Mats Kindahl
23d8586dbf WL#5030: Split and remove mysql_priv.h
This patch:

- Moves all definitions from the mysql_priv.h file into
  header files for the component where the variable is
  defined
- Creates header files if the component lacks one
- Eliminates all include directives from mysql_priv.h
- Eliminates all circular include cycles
- Rename time.cc to sql_time.cc
- Rename mysql_priv.h to sql_priv.h
2010-03-31 16:05:33 +02:00
Alexey Kopytov
d95c1e3b47 Manual merge of mysql-trunk into mysql-trunk-merge.
Conflicts:

Text conflict in client/mysqlbinlog.cc
Text conflict in mysql-test/Makefile.am
Text conflict in mysql-test/collections/default.daily
Text conflict in mysql-test/r/mysqlbinlog_row_innodb.result
Text conflict in mysql-test/suite/rpl/r/rpl_typeconv_innodb.result
Text conflict in mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test
Text conflict in mysql-test/suite/rpl/t/rpl_row_create_table.test
Text conflict in mysql-test/suite/rpl/t/rpl_slave_skip.test
Text conflict in mysql-test/suite/rpl/t/rpl_typeconv_innodb.test
Text conflict in mysys/charset.c
Text conflict in sql/field.cc
Text conflict in sql/field.h
Text conflict in sql/item.h
Text conflict in sql/item_func.cc
Text conflict in sql/log.cc
Text conflict in sql/log_event.cc
Text conflict in sql/log_event_old.cc
Text conflict in sql/mysqld.cc
Text conflict in sql/rpl_utility.cc
Text conflict in sql/rpl_utility.h
Text conflict in sql/set_var.cc
Text conflict in sql/share/Makefile.am
Text conflict in sql/sql_delete.cc
Text conflict in sql/sql_plugin.cc
Text conflict in sql/sql_select.cc
Text conflict in sql/sql_table.cc
Text conflict in storage/example/ha_example.h
Text conflict in storage/federated/ha_federated.cc
Text conflict in storage/myisammrg/ha_myisammrg.cc
Text conflict in storage/myisammrg/myrg_open.c
2010-03-24 18:03:44 +03:00
Alexey Kopytov
5d407d0c1a Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts:

Text conflict in mysql-test/r/partition_innodb.result
Text conflict in sql/field.h
Text conflict in sql/item.h
Text conflict in sql/item_cmpfunc.h
Text conflict in sql/item_sum.h
Text conflict in sql/log_event_old.cc
Text conflict in sql/protocol.cc
Text conflict in sql/sql_select.cc
Text conflict in sql/sql_yacc.yy
2010-03-20 23:23:42 +03:00
Mats Kindahl
96d4a03846 Merging with mysql-5.1-bugteam 2010-03-17 19:15:41 +01:00
Mats Kindahl
2c5f439d65 BUG#49618: Field length stored incorrectly in binary log
for InnoDB
            
The class Field_bit_as_char stores the metadata for the
field incorrecly because bytes_in_rec and bit_len are set
to (field_length + 7 ) / 8 and 0 respectively, while
Field_bit has the correct values field_length / 8 and
field_length % 8.
            
Solved the problem by re-computing the values for the
metadata based on the field_length instead of using the
bytes_in_rec and bit_len variables.
            
To handle compatibility with old server, a table map
flag was added to indicate that the bit computation is
exact. If the flag is clear, the slave computes the
number of bytes required to store the bit field and
compares that instead, effectively allowing replication
*without conversion* from any field length that require
the same number of bytes to store.


mysql-test/suite/rpl/t/rpl_typeconv_innodb.test:
  Adding test to check compatibility for bit field
  replication when using InnoDB
sql/field.cc:
  Extending compatible_field_size() with flags from
  table map to allow fields to check master info.
sql/field.h:
  Extending compatible_field_size() with flags from
  table map to allow fields to check master info.
sql/log.cc:
  Removing table map flags since they are not used
  outside table map class.
sql/log_event.cc:
  Removing flags parameter from table map constructor
  since it is not used and does not have to be exposed.
sql/log_event.h:
  Adding flag to denote that bit length for bit field type
  is exact and not potentially rounded to even bytes.
sql/rpl_utility.cc:
  Adding fields to table_def to store table map flags.
sql/rpl_utility.h:
  Removing obsolete comment and adding flags to store
  table map flags from master.
2010-03-17 15:28:49 +01:00
Martin Hansson
7dc693229f Bug#47762: Incorrect result from MIN() when WHERE tests NOT
NULL column for NULL

The optimization to read MIN() and MAX() values from an
index did not properly handle comparisons with NULL
values. Fixed by giving up the particular optimization step
if there are non-NULL safe comparisons with NULL values, as 
the result is NULL anyway.

Also, Oracle copyright notice was added to all files.
2010-03-16 15:51:00 +01:00
Alexander Barkov
7a83782f1c Mergine from mysql-next-me 2010-02-27 11:43:32 +04:00
Alexander Barkov
702166bcde WL#2649 Number-to-string conversions
added:
  include/ctype_numconv.inc
  mysql-test/include/ctype_numconv.inc
  mysql-test/r/ctype_binary.result
  mysql-test/t/ctype_binary.test
  Adding tests

modified:

  mysql-test/r/bigint.result
  mysql-test/r/case.result
  mysql-test/r/create.result
  mysql-test/r/ctype_cp1251.result
  mysql-test/r/ctype_latin1.result
  mysql-test/r/ctype_ucs.result
  mysql-test/r/func_gconcat.result
  mysql-test/r/func_str.result
  mysql-test/r/metadata.result
  mysql-test/r/ps_1general.result
  mysql-test/r/ps_2myisam.result
  mysql-test/r/ps_3innodb.result
  mysql-test/r/ps_4heap.result
  mysql-test/r/ps_5merge.result
  mysql-test/r/show_check.result
  mysql-test/r/type_datetime.result
  mysql-test/r/type_ranges.result
  mysql-test/r/union.result
  mysql-test/suite/ndb/r/ps_7ndb.result
  mysql-test/t/ctype_cp1251.test
  mysql-test/t/ctype_latin1.test
  mysql-test/t/ctype_ucs.test
  mysql-test/t/func_str.test
    Fixing tests


  @ sql/field.cc
     - Return str result using my_charset_numeric.
     - Using real multi-byte aware str_to_XXX functions
       to handle tricky charset values propely (e.g. UCS2)
  @ sql/field.h
     - Changing derivation of non-string field types to DERIVATION_NUMERIC.
     - Changing binary() for numeric/datetime fields to always
     return TRUE even if charset is not my_charset_bin. We need
     this to keep ha_base_keytype() return HA_KEYTYPE_BINARY.
     - Adding BINARY_FLAG into some fields, because it's not
     being set automatically anymore with
     "my_charset_bin to my_charset_numeric" change.
    - Changing derivation for numeric/datetime datatypes to a weaker
      value, to make "SELECT concat('string', field)" use character
      set of the string literal for the result of the function.
  @ sql/item.cc
     - Implementing generic val_str_ascii().
     - Using max_char_length() instead of direct read of max_length
       to make "tricky" charsets like UCS2 work.
       NOTE: in the future we'll possibly remove all direct reads of max_length
     - Fixing Item_num::safe_charset_converter().
       Previously it alligned binary string to
       character string (for example by adding leading 0x00
       when doing binary->UCS2 conversion). Now it just
       converts from my_charset_numbner to "tocs".
     - Using val_str_ascii() in Item::get_time() to make UCS2 arguments work.
     - Other misc changes
  @ sql/item.h
     - Changing MY_COLL_CMP_CONV and MY_COLL_ALLOW_CONV to
       bit operations instead of hard-coded bit masks.
     - Addding new method DTCollation.set_numeric().
     - Adding new methods to Item.
     - Adding helper functions to make code look nicer:
       agg_item_charsets_for_string_result()
       agg_item_charsets_for_comparison()
     - Changing charset for Item_num-derived items
       from my_charset_bin to my_charset_numeric
       (which is an alias for latin1).
  @ sql/item_cmpfunc.cc
     - Using new helper functions
     - Other misc changes
  @ sql/item_cmpfunc.h
     - Fixing strcmp() to return max_length=2.
       Previously it returned 1, which was wrong,
       because it did not fit '-1'.
  @ sql/item_func.cc
     - Using new helper functions
     - Other minor changes
  @ sql/item_func.h
     - Removing unused functions
     - Adding helper functions
       agg_arg_charsets_for_string_result()
       agg_arg_charsets_for_comparison()
     - Adding set_numeric() into constructors of numeric items.
     - Using fix_length_and_charset() and fix_char_length()
       instead of direct write to max_length.
  @ sql/item_geofunc.cc
     - Changing class for Item_func_geometry_type and
       Item_func_as_wkt from Item_str_func to
       Item_str_ascii_func, to make them return UCS2 result
       properly (when character_set_connection=ucs2).
  @ sql/item_geofunc.h
     - Changing class for Item_func_geometry_type and
       Item_func_as_wkt from Item_str_func to
       Item_str_ascii_func, to make them return UCS2 result
       properly (when @@character_set_connection=ucs2).
  @ sql/item_strfunc.cc
     - Implementing Item_str_func::val_str().
     - Renaming val_str to val_str_ascii for some items,
       to make them work with UCS2 properly.
     - Using new helper functions
     - All single-argument functions that expect string
       result now call this method:
       agg_arg_charsets_for_string_result(collation, args, 1);
       This enables character set conversion to @@character_set_connection
       in case of pure numeric input.
  @ sql/item_strfunc.h
     - Introducing Item_str_ascii_func - for functions
       which return pure ASCII data, for performance purposes,
       as well as for the cases when the old implementation
       of val_str() was heavily 8-bit oriented and implementing
       a UCS2-aware version is tricky.
  @ sql/item_sum.cc
     - Using new helper functions.
  @ sql/item_timefunc.cc
     - Using my_charset_numeric instead of my_charset_bin.
     - Using fix_char_length(), fix_length_and_charset()
       and fix_length_and_charset_datetime()
       instead of direct write to max_length.
     - Using tricky-charset aware function str_to_time_with_warn()
  @ sql/item_timefunc.h
     - Using new helper functions for charset and length initialization.
     - Changing base class for Item_func_get_format() to make
       it return UCS2 properly (when character_set_connection=ucs2).
  @ sql/item_xmlfunc.cc
     - Using new helper function
  @ sql/my_decimal.cc
     - Adding a new DECIMAL to CHAR converter
       with real multibyte support (e.g. UCS2)

  @ sql/mysql_priv.h
     - Introducing a new derivation level for numeric/datetime data types.
     - Adding macros for my_charset_numeric and MY_REPERTOIRE_NUMERIC.
     - Adding prototypes for str_set_decimal()
     - Adding prototypes for character-set aware str_to_xxx() functions.
  @ sql/protocol.cc
     - Changing charsetnr to "binary" client-side metadata for
       numeric/datetime data types.
  @ sql/time.cc
     - Adding to_ascii() helper function, to convert a string
       in any character set to ascii representation. In the
       future can be extended to understand digits written
       in various non-Latin word scripts.
     - Adding real multy-byte character set aware versions for str_to_XXXX,
       to make these these type of queries work correct:
         INSERT INTO t1 SET datetime_column=ucs2_expression;
   @  strings/ctype-ucs2.c
     - endptr was not calculated correctly. INSERTing of UCS2
       values into numeric columns returned warnings about
       truncated wrong data.
2010-02-11 08:17:25 +04:00
Konstantin Osipov
a72f90bc43 Merge next-mr -> next-4284.
mysql-test/t/disabled.def:
  Restore disabled ssl tests: SSL certificates were updated.
  Disable sp_sync.test, the test case can't work in next-4284.
mysql-test/t/partition_innodb.test:
  Disable parsing of the test case for Bug#47343, 
  the test can not work in next-4284.
mysql-test/t/ps_ddl.test:
  Update results (CREATE TABLE IF NOT EXISTS takes
  into account existence of the temporary table).
2010-02-06 13:28:06 +03:00
Konstantin Osipov
e7b332ba83 Merge next-mr -> next-4284. 2010-02-05 01:08:08 +03:00
Konstantin Osipov
665100b69d Merge next-mr -> next-4284. 2010-02-02 02:22:16 +03:00
Alexander Nozdrin
077e7c9a87 Manual merge from mysql-trunk-merge.
Conflicts:
  - mysql-test/collections/default.experimental
  - mysql-test/suite/rpl/r/rpl_get_master_version_and_clock.result
  - mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test
2010-01-31 00:26:38 +03:00
Alexander Nozdrin
0da16c7c2a Manual merge from mysql-5.1-bugteam.
Conflicts:
  - mysql-test/collections/default.experimental
  - mysql-test/suite/rpl/r/rpl_binlog_grant.result
  - mysql-test/suite/rpl/r/rpl_sp.result
  - mysql-test/suite/rpl/t/rpl_binlog_grant.test
  - mysql-test/suite/rpl/t/rpl_get_master_version_and_clock.test
2010-01-30 22:13:36 +03:00
Luis Soares
73f10f0662 BUG#49481: RBR: MyISAM and bit fields may cause slave to stop on delete:
cant find record

Some engines return data for the record. Despite the fact that
the null bit is set for some fields, their old value may still in
the row. This can happen when unpacking an AI from the binlog on
top of a previous record in which a field is set to NULL, which
previously contained a value. Ultimately, this may cause the
comparison of records to fail when the slave is doing an index or
range scan.

We fix this by deploying a call to reset() for each field that is
set to null while unpacking a row from the binary log.
Furthermore, we also add mixed mode test case to cover the
scenario where updating and setting a field to null through a
Query event and later searching it through a rows event will
succeed.

Finally, we also change the reset() method, from Field_bit class,
so that it takes into account bits stored among the null bits and
not only the ones stored in the record.

mysql-test/suite/rpl/t/rpl_set_null_innodb.test:
  InnoDB test.
mysql-test/suite/rpl/t/rpl_set_null_myisam.test:
  MyISAM test.
mysql-test/suite/rpl_ndb/t/rpl_ndb_set_null.test:
  NDB test.
sql/field.h:
  Changed reset so that it also clears the bits
  among the null_bits for the Field_bit class.
sql/rpl_record.cc:
  Resetting field after setting it to null when unpacking
  row.
2010-01-21 17:20:24 +00:00
Alfranio Correia
5dcb0e447f merge mysql-5.1-rep+2-delivery1 --> mysql-5.1-rpl-merge
Conflicts:

Text conflict in .bzr-mysql/default.conf
Text conflict in mysql-test/extra/rpl_tests/rpl_loaddata.test
Text conflict in mysql-test/r/mysqlbinlog2.result
Text conflict in mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
Text conflict in mysql-test/suite/binlog/r/binlog_unsafe.result
Text conflict in mysql-test/suite/rpl/r/rpl_insert_id.result
Text conflict in mysql-test/suite/rpl/r/rpl_loaddata.result
Text conflict in mysql-test/suite/rpl/r/rpl_stm_auto_increment_bug33029.result
Text conflict in mysql-test/suite/rpl/r/rpl_udf.result
Text conflict in mysql-test/suite/rpl/t/rpl_slow_query_log.test
Text conflict in sql/field.h
Text conflict in sql/log.cc
Text conflict in sql/log_event.cc
Text conflict in sql/log_event_old.cc
Text conflict in sql/mysql_priv.h
Text conflict in sql/share/errmsg.txt
Text conflict in sql/sp.cc
Text conflict in sql/sql_acl.cc
Text conflict in sql/sql_base.cc
Text conflict in sql/sql_class.h
Text conflict in sql/sql_db.cc
Text conflict in sql/sql_delete.cc
Text conflict in sql/sql_insert.cc
Text conflict in sql/sql_lex.cc
Text conflict in sql/sql_lex.h
Text conflict in sql/sql_load.cc
Text conflict in sql/sql_table.cc
Text conflict in sql/sql_update.cc
Text conflict in sql/sql_view.cc
Conflict adding files to storage/innobase.  Created directory.
Conflict because storage/innobase is not versioned, but has versioned children.  Versioned directory.
Conflict adding file storage/innobase.  Moved existing file to storage/innobase.moved.
Conflict adding files to storage/innobase/handler.  Created directory.
Conflict because storage/innobase/handler is not versioned, but has versioned children.  Versioned directory.
Contents conflict in storage/innobase/handler/ha_innodb.cc
2010-01-07 15:39:11 +00:00
Alfranio Correia
9a51ad2c54 merging from 5.1 to rep+2 starting at gca(5.1, next-mr) == build@mysql.com-20091208092611-pbno5awyb0v38hs7
Fixed conflicts in:

- binlog.binlog_unsafe
- rpl.rpl_slow_query_log
2009-12-17 00:09:52 +00:00
Mats Kindahl
f9abd14225 Merging with mysql-5.1-rep+2 2009-12-15 21:21:00 +01:00
Mats Kindahl
9e980bf79e BUG#49618: Field length stored incorrectly in binary log
for InnoDB

The class Field_bit_as_char stores the metadata for the
field incorrecly because bytes_in_rec and bit_len are set
to (field_length + 7 ) / 8 and 0 respectively, while
Field_bit has the correct values field_length / 8 and
field_length % 8.

Solved the problem by re-computing the values for the
metadata based on the field_length instead of using the
bytes_in_rec and bit_len variables.

To handle compatibility with old server, a table map
flag was added to indicate that the bit computation is
exact. If the flag is clear, the slave computes the
number of bytes required to store the bit field and
compares that instead, effectively allowing replication
*without conversion* from any field length that require
the same number of bytes to store.

mysql-test/suite/rpl/t/rpl_typeconv_innodb.test:
  Adding test to check compatibility for bit field
  replication when using InnoDB.
sql/field.cc:
  Extending compatible_field_size() with flags from
  table map to allow fields to check master info.
sql/field.h:
  Extending compatible_field_size() with flags from
  table map to allow fields to check master info.
sql/log.cc:
  Removing table map flags since they are not used
  outside table map class.
sql/log_event.cc:
  Removing flags parameter from table map constructor
  since it is not used and does not have to be exposed.
sql/log_event.h:
  Adding flag to denote that bit length for bit field type
  is exact and not potentially rounded to even bytes.
sql/rpl_utility.cc:
  Adding fields to table_def to store table map flags.
sql/rpl_utility.h:
  Removing obsolete comment and adding flags to store
  table map flags from master.
2009-12-15 16:11:44 +01:00
Mats Kindahl
571843804c WL#5151: Conversion between different types when replicating
Row-based replication requires the types of columns on the
master and slave to be approximately the same (some safe
conversions between strings are allowed), but does not
allow safe conversions between fields of similar types such
as TINYINT and INT.

This patch implement type conversions between similar fields
on the master and slave.

The conversions are controlled using a new variable
SLAVE_TYPE_CONVERSIONS of type SET('ALL_LOSSY','ALL_NON_LOSSY').

Non-lossy conversions are any conversions that do not run the
risk of losing any information, while lossy conversions can
potentially truncate the value. The column definitions are
checked to decide if the conversion is acceptable.

If neither conversion is enabled, it is required that the
definitions of the columns are identical on master and slave.

Conversion is done by creating an internal conversion table,
unpacking the master data into it, and then copy the data to
the real table on the slave.

.bzrignore:
  New files added
client/Makefile.am:
  New files added
client/mysqlbinlog.cc:
  Functions in rpl_utility.cc is now needed by mysqlbinlog.cc.
libmysqld/Makefile.am:
  New files added
mysql-test/extra/rpl_tests/check_type.inc:
  Test include file to check a single type conversion.
mysql-test/extra/rpl_tests/rpl_extraSlave_Col.test:
  Switching to use INT instead of TEXT for column that should not have matching types.
mysql-test/extra/rpl_tests/rpl_row_basic.test:
  Adding code to enable type conversions for BIT tests since InnoDB
  cannot handle them properly due to incorrect information stored as
  metadata.
mysql-test/extra/rpl_tests/type_conversions.test:
  Test file to check a set of type conversions
  with current settings of slave_type_conversions.
mysql-test/suite/rpl/t/rpl_typeconv.test:
  Test file to test conversions from master to slave with
  all possible values for slave_type_conversions.
  
  The test also checks that the slave_type_conversions
  variable works as expected.
sql/field.cc:
  Changing definition of compatible_field_size to both check if 
  two field with identical base types are compatible and give an
  order between them if they are compatible.
  
  This only implement checking on the slave, so it will not affect
  replication from an old master to a new slave.
sql/field.h:
  Changing prototypes for functions:
  - compatible_field_size()
  - init_for_tmp_table()
  - row_pack_length()
sql/log_event.cc:
  Changing compability checks to build a conversion table if the fields
  are compatible, but does not have the same base type.
sql/log_event_old.cc:
  Changing compability checks to build a conversion table if the fields
  are compatible, but does not have the same base type.
sql/mysql_priv.h:
  Adding global option variable for SLAVE_TYPE_CONVERSIONS
sql/mysqld.cc:
  Adding SLAVE_TYPE_CONVERSIONS global server variable.
sql/rpl_record.cc:
  Changing unpack_row to use the conversion table if present.
sql/rpl_rli.h:
  Removing function get_tabledef and replacing it with get_table_data().
  This function retrieve data for table opened for replication, not just
  table definition.
sql/rpl_utility.cc:
  Function table_def::compatible_with is changed to compare table on master
  and slave for compatibility and generate a conversions table if they are
  compatible.
  
  Computing real type of fields from metadata for ENUM and SET types.
  Computing pack_length correctly for ENUM, SET, and BLOB types.
  
  Adding optimization to not check compatibility if no
  slave type conversions are enabled.
sql/rpl_utility.h:
  Changing prototypes since implementation has changed.
  
  Modifying table_def::type() to return real type instead of stored type.
sql/set_var.cc:
  Adding SLAVE_TYPE_CONVERSIONS variable.
sql/set_var.h:
  Adding SLAVE_TYPE_CONVERSIONS variable.
sql/share/errmsg.txt:
  Adding error messages for slave type conversions.
sql/sql_class.h:
  Adding SLAVE_TYPE_CONVERSIONS variable.
sql/sql_select.cc:
  Correcting create_virtual_tmp_table() to compute null bit positions
  correctly in the presence of bit fields.
2009-12-14 12:04:55 +01:00
Alexander Nozdrin
aceea2342f Manual merge from mysql-trunk-merge.
Conflicts:
  - extra/comp_err.c
  - mysql-test/collections/default.experimental
  - mysql-test/r/archive.result
  - mysql-test/r/select.result
  - mysql-test/suite/binlog/r/binlog_unsafe.result
  - mysql-test/suite/binlog/t/binlog_unsafe.test
  - mysql-test/suite/rpl/t/disabled.def
  - mysql-test/t/archive.test
  - mysql-test/t/select.test
  - sql/item.cc
  - sql/item.h
  - sql/item_timefunc.cc
  - sql/sql_base.cc
  - sql/sql_delete.cc
  - sql/sql_load.cc
  - sql/sql_partition.cc
  - sql/sql_table.cc
  - storage/innobase/handler/ha_innodb.cc
  - vio/vio.c
2009-12-12 23:38:59 +03:00
Alexander Nozdrin
5676713687 Manual merge from mysql-trunk.
Conflicts:
  - client/mysqltest.cc
  - mysql-test/collections/default.experimental
  - mysql-test/suite/rpl/t/disabled.def
  - sql/mysqld.cc
  - sql/opt_range.cc
  - sql/sp.cc
  - sql/sql_acl.cc
  - sql/sql_partition.cc
  - sql/sql_table.cc
2009-12-11 12:39:38 +03:00
Konstantin Osipov
3104af49cd Backport of:
----------------------------------------------------------
revno: 2630.10.1
committer: Konstantin Osipov <konstantin@mysql.com>
branch nick: mysql-6.0-lock-tables-tidyup
timestamp: Wed 2008-06-11 15:49:58 +0400
message:
  WL#3726, review fixes.
  Now that we have metadata locks, we don't need to keep a crippled
  TABLE instance in the table cache to indicate that a table is locked.
  Remove all code that used this technique. Instead, rely on metadata
  locks and use the standard open_table() and close_thread_table()
  to manipulate with the table cache tables.
  Removes a list of functions that have become unused (see the comment
  for sql_base.cc for details).
  Under LOCK TABLES, keep a TABLE_LIST instance for each table
  that may be temporarily closed. For that, implement an own class for
  LOCK TABLES mode, Locked_tables_list.

This is a pre-requisite patch for WL#4144.
This is not exactly a backport: there is no new 
online ALTER table in Celosia, so the old alter table
code was changed to work with the new table cache API.


mysql-test/r/lock.result:
  Update results (WL#3726 post-review patch).
mysql-test/r/trigger-compat.result:
  We take the table from the table cache now, thus no warning.
mysql-test/suite/rpl/r/rpl_trigger.result:
  We take the table from the table cache now, thus no warning.
mysql-test/t/lock.test:
  Additional tests for LOCK TABLES mode (previously not covered by
  the test suite (WL#3726).
sql/field.h:
  Remove reopen_table().
sql/lock.cc:
  Remove an obsolete parameter of mysql_lock_remove().
  It's not used anywhere now either.
sql/mysql_priv.h:
  Add 4 new open_table() flags.
  Remove declarations of removed functions.
sql/sp_head.cc:
  Rename thd->mdl_el_root to thd->locked_tables_root.
sql/sql_acl.cc:
  Use the new implementation of unlock_locked_tables().
sql/sql_base.cc:
  Implement class Locked_tables_list.
  Implement close_all_tables_for_name().
  Rewrite close_cached_tables() to use the new reopen_tables().
  Remove reopen_table(), reopen_tables(), reopen_table_entry() 
  (ex. open_unireg_entry()), close_data_files_and_leave_as_placeholders(),
  close_handle_and_leave_table_as_placeholder(), close_cached_table(),
  table_def_change_share(), reattach_merge(), reopen_name_locked_table(),
  unlink_open_table().
  
  Move acquisition of a metadata lock into an own function
  - open_table_get_mdl_lock().
sql/sql_class.cc:
  Deploy class Locked_tables_list.
sql/sql_class.h:
  Declare class Locked_tables_list.
  Keep one instance of this class in class THD.
  Rename mdl_el_root to locked_tables_root.
sql/sql_db.cc:
  Update a comment.
sql/sql_insert.cc:
  Use the plain open_table() to open a just created table in
  CREATE TABLE .. SELECT.
sql/sql_parse.cc:
  Use thd->locked_tables_list to enter and leave LTM_LOCK_TABLES mode.
sql/sql_partition.cc:
  Deploy the new method of working with partitioned table locks.
sql/sql_servers.cc:
  Update to the new signature of unlock_locked_tables().
sql/sql_table.cc:
  In mysql_rm_table_part2(), the branch that removes a table under
  LOCK TABLES, make sure that the table being dropped
  is also removed from THD::locked_tables_list.
  Update ALTER TABLE and CREATE TABLE LIKE implementation to use
  open_table() and close_all_tables_for_name() instead of 
  reopen_tables().
sql/sql_trigger.cc:
  Use the new locking way.
sql/table.h:
  Add TABLE::pos_in_locked_tables, which is used only under
  LOCK TABLES.
2009-12-02 18:22:15 +03:00
Andrei Elkin
3962da934f merging from 5.1 to rep+2 starting at gca(5.1, next-mr) == build@mysql.com-20091104182209-iui387z35159aoyw 2009-11-30 14:34:39 +02:00
Georgi Kodinov
a21cd97c35 Bug #45261 : Crash, stored procedure + decimal
Bug #48370  Absolutely wrong calculations with GROUP BY and
  decimal fields when using IF

Added the test cases in the above two bugs for regression
testing.
Added additional tests that demonstrate a incomplete fix.
Added a new factory method for Field_new_decimal to 
create a field from an (decimal returning) Item.
In the new method made sure that all the precision and 
length variables are capped in a proper way. 
This is required because Item's can have larger precision
than the decimal fields and thus need to be capped when
creating a field based on an Item type.
Fixed the wrong typecast to Item_decimal.
2009-11-20 12:10:47 +02:00
Davi Arnaut
5aeeaaf507 Manual merge of mysql-next-mr-runtime upstream. 2009-11-19 21:48:08 -02:00
Magne Mahre
56e603a31b Bug #33544 UDF_INIT member decimals initialized wrong with
STRING_RESULT argument

There is a "magic" number for precision : NOT_FIXED_DEC. 
This means that the precision is not a fixed number.
But this constant was re-defined in several files and 
was not available to the UDF developers.
 
Moved the NOT_FIXED_DEC definition to the correct header
and removed the redundant definitions.

Backported to 5.6.0  (mysql-next-mr-runtime)

client/sql_string.h:
  moved NOT_FIXED_DEC to the correct header
include/mysql_com.h:
  moved NOT_FIXED_DEC to the correct header
libmysql/libmysql.c:
  moved NOT_FIXED_DEC to the correct header
sql/field.h:
  moved NOT_FIXED_DEC to the correct header
sql/sql_string.h:
  moved NOT_FIXED_DEC to the correct header
storage/ndb/include/kernel/signaldata/DictTabInfo.hpp:
  moved NOT_FIXED_DEC to the correct header
2009-11-11 21:19:41 +01:00
Davi Arnaut
891dffa322 Backport of Bug#45767 to mysql-next-mr
------------------------------------------------------------
revno: 3405
revision-id: davi.arnaut@sun.com-20090626124624-m4wolyo5193j4cu7
parent: luis.soares@sun.com-20090626113019-1j4mn1jos480u9f3
committer: Davi Arnaut <Davi.Arnaut@Sun.COM>
branch nick: mysql-pe
timestamp: Fri 2009-06-26 09:46:24 -0300
message:
  Bug#45767: deprecate/remove Field::pack_key, Field::unpack_key, Field::pack_cmp
  
  Remove unused and dead code.
  
  Parts of the patch contributed by Zardosht Kasheff
2009-11-10 18:51:14 -02:00
Andrei Elkin
3c1e1f6d6c merging 5.1 main -> rpl+2. Some manual work required mostly due to bug46640 2009-11-06 18:35:04 +02:00
Alexander Nozdrin
7cd11f45be Manual merge from mysql-trunk-merge. 2009-11-06 17:20:27 +03:00
Alexander Nozdrin
c502279342 Backport a patch from 6.0:
------------------------------------------------------------
revno: 2599.178.12
revision-id: alik@mysql.com-20080812161845-we7cx9f22yrghob1
committer: Alexander Nozdrin <alik@mysql.com>
branch nick: 6.0-rt-build
timestamp: Tue 2008-08-12 20:18:45 +0400
message:
  Fix memory leak.
------------------------------------------------------------
2009-11-02 17:17:14 +03:00
Davi Arnaut
1ca80ed19e Bug#48370: Absolutely wrong calculations with GROUP BY and decimal fields when using IF
Bug#45261: Crash, stored procedure + decimal

Revert fix for Bug#45261 due to unforeseen bugs.
2009-11-02 09:21:39 -02:00
Alexander Nozdrin
22fe8e10e2 Merge from mysql-next-mr. 2009-10-28 10:55:44 +03:00
Alexander Nozdrin
2dc132b209 Merge from mysql-next-mr. 2009-10-23 15:22:21 +04:00