Commit graph

705 commits

Author SHA1 Message Date
Sergei Golubchik
f1a5c49c4e various fixes for buildbot failures 2011-06-10 15:42:55 +02:00
Sergei Golubchik
9b98cae4cc merge with 5.1-micro 2011-06-07 18:13:02 +02:00
Michael Widenius
f197991f41 Merge with 5.1-microseconds
A lot of small fixes and new test cases.

client/mysqlbinlog.cc:
  Cast removed
client/mysqltest.cc:
  Added missing DBUG_RETURN
include/my_pthread.h:
  set_timespec_time_nsec() now only takes one argument
mysql-test/t/date_formats.test:
  Remove --disable_ps_protocl as now also ps supports microseconds
mysys/my_uuid.c:
  Changed to use my_interval_timer() instead of my_getsystime()
mysys/waiting_threads.c:
  Changed to use my_hrtime()
sql/field.h:
  Added bool special_const_compare() for fields that may convert values before compare (like year)
sql/field_conv.cc:
  Added test to get optimal copying of identical temporal values.
sql/item.cc:
  Return that item_int is equal if it's positive, even if unsigned flag is different.
  Fixed Item_cache_str::save_in_field() to have identical null check as other similar functions
  Added proper NULL check to Item_cache_int::save_in_field()
sql/item_cmpfunc.cc:
  Don't call convert_constant_item() if there is nothing that is worth converting.
  Simplified test when years should be converted
sql/item_sum.cc:
  Mark cache values in Item_sum_hybrid as not constants to ensure they are not replaced by other cache values in compare_datetime()
sql/item_timefunc.cc:
  Changed sec_to_time() to take a my_decimal argument to ensure we don't loose any sub seconds.
  Added Item_temporal_func::get_time() (This simplifies some things)
sql/mysql_priv.h:
  Added Lazy_string_decimal()
sql/mysqld.cc:
  Added my_decimal constants max_seconds_for_time_type, time_second_part_factor
sql/table.cc:
  Changed expr_arena to be of type CONVENTIONAL_EXECUTION to ensure that we don't loose any items that are created by fix_fields()
sql/tztime.cc:
  TIME_to_gmt_sec() now sets *in_dst_time_gap in case of errors
  This is needed to be able to detect if timestamp is 0
storage/maria/lockman.c:
  Changed from my_getsystime() to set_timespec_time_nsec()
storage/maria/ma_loghandler.c:
  Changed from my_getsystime() to my_hrtime()
storage/maria/ma_recovery.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/maria/unittest/trnman-t.c:
  Changed from my_getsystime() to mmicrosecond_interval_timer()
storage/xtradb/handler/ha_innodb.cc:
  Added support for new time,datetime and timestamp
unittest/mysys/thr_template.c:
  my_getsystime() -> my_interval_timer()
unittest/mysys/waiting_threads-t.c:
  my_getsystime() -> my_interval_timer()
2011-05-28 05:11:32 +03:00
Sergei Golubchik
03b33425e5 many changes to my_getsystime.c:
* my_getsystime() is only an interval timer. Its value can beused for calculating
  time intervals.
* renamed my_getsystime() to my_interval_timer(), to make the semantics
  clearer and let the compiler catch wrong usages of my_getsystime()
  (also future ones, that may come in merges).
* increased its granularity from 100ns to 1ns, old value was for UUID,
  but as UUID can no longer use it directly there is no need to downgrade
  the OS provided value
* fixed the UUID code to anchor the my_interval_timer() on the epoch, as
  required by the UUID standard. That is, this was only needed by UUID,
  and now I've moved it to UUID code from my_getsystime().
* fixed other wrong usages of my_getsystime() - e.g. in calculating
  times for pthread_cond_timedwait. It was buggy and could've caused
  long waits if OS clock would be changed.
2011-05-19 19:05:35 +02:00
Michael Widenius
f09f1c7c7d Merge with dynamic column code 2011-05-12 14:30:34 +03:00
Michael Widenius
052d1bfb1a Fixed all reported bugs for dynamic columns.
Bugs fixed:
- Added automatic detection of unsigned arguments to COLUMN_CREATE()
- If string length is not know for COLUMN_GET() use MAX_DYNAMIC_COLUMN_LENGTH instead of MAX_FIELD_BLOBLENGTH
- null_value flag was not propery reset for COLUMN_LIST() and COLUMN_CREATE() which could lead to crashes later:
- lp:778905 Assertion `value->year <= 9999' failed in dynamic_column_date_store
- lp:778912 Assertion `field_pos < field_count' failed in Protocol_text::store in maria-5.3-mwl34

include/ma_dyncol.h:
  Added define for max dynamic column length.
mysql-test/r/cast.result:
  Added test of cast big unsigned int to signed (this test case was missing)
mysql-test/r/dyncol.result:
  Added tests from reported bugs
  Added testing of automatic store of signed/unsigned integers
mysql-test/t/cast.test:
  Added test of cast big unsigned int to signed (this test case was missing)
mysql-test/t/dyncol.test:
  Added tests from reported bugs
  Added testing of automatic store of signed/unsigned integers
sql/item.cc:
  Added assert to catch cases where null_value is not set properly
sql/item_strfunc.cc:
  Added automatic detection of unsigned arguments to COLUMN_CREATE()
  COLUMN_GET() returned wrong value for illegal strings which lead to assert later
  null_value flag was not propery reset for COLUMN_LIST() and COLUMN_CREATE() which could lead to crashes later.
sql/item_strfunc.h:
  If string length is not know for COLUMN_GET() use MAX_DYNAMIC_COLUMN_LENGTH
2011-05-11 02:41:02 +03:00
Michael Widenius
f34be18938 Merge with MariaDB 5.2 2011-05-10 18:17:43 +03:00
Michael Widenius
5ab92b1f85 Adding support for Dynamic columns (WL#34):
- COLUMN_CREATE(column_nr, value, [column_nr,value]...)
- COLUMN_ADD(blob,column_nr, value, column_nr,value]...)
- COLUMN_DELETE(blob, column_nr, column_nr...)
- COLUMN_EXISTS(blob, column_nr)
- COLUMN_LIST(blob, column_nr)
- COLUMN_GET(string, column_nr AS type)

Added cast(X as DOUBLE) and cast(x as INT)
Better warning and error messages for wrong cast's
Created some sub functions to simplify and reuse code.
Added a lot of conversation functions with error/warnings for what went wrong.
Fixed some issues when casting time to datetime.
Added functions to dynamic strings and Strings to allow one to move a string buffer from dynamic strings to String (to save malloc+ copy)
Added dynamic columns library to libmysqlclient


include/Makefile.am:
  Added ma_dyncol.h
include/decimal.h:
  Added 'const' to arguments for some functions.
include/my_sys.h:
  Added dynstr_reassociate()
include/my_time.h:
  Added TIME_SUBSECOND_RANGE
  Added double_to_datetime()
  Added flag argument to str_to_time()
libmysql/CMakeLists.txt:
  Added mysys/ma_dyncol.c
libmysql/Makefile.shared:
  Added ma_dyncol
libmysql/libmysql.c:
  Added argument to str_to_time()
mysql-test/r/bigint.result:
  Better error messages
mysql-test/r/cast.result:
  Better warning and error messages
  A lot of new cast() tests
mysql-test/r/func_math.result:
  Better warning messages
mysql-test/r/func_str.result:
  Better warning messages
mysql-test/r/func_time.result:
  Better warning messages
mysql-test/r/sp-vars.result:
  Better warning messages
mysql-test/r/strict.result:
  Better warning messages
  New test result
mysql-test/r/type_newdecimal.result:
  Better warning messages
mysql-test/r/warnings.result:
  Better warning messages
mysql-test/suite/funcs_1/r/innodb_func_view.result:
  Updated results after better cast warnings
mysql-test/suite/funcs_1/r/memory_func_view.result:
  Updated results after better cast warnings
mysql-test/suite/funcs_1/r/myisam_func_view.result:
  Updated results after better cast warnings
mysql-test/suite/optimizer_unfixed_bugs/t/bug43448.test:
  Added begin...commit to speed up test.
mysql-test/suite/parts/inc/part_supported_sql_funcs_delete.inc:
  Added begin...commit to speed up test.
mysql-test/suite/parts/inc/partition_supported_sql_funcs.inc:
  Added begin...commit to speed up test.
mysql-test/suite/parts/r/part_supported_sql_func_innodb.result:
  Added begin...commit to speed up test.
mysql-test/suite/parts/r/part_supported_sql_func_myisam.result:
  Added begin...commit to speed up test.
mysql-test/suite/parts/r/rpl_partition.result:
  Added begin...commit to speed up test.
mysql-test/suite/parts/t/part_supported_sql_func_innodb.test:
  Removed duplicated --big_test
mysql-test/suite/parts/t/rpl_partition.test:
  Added begin...commit to speed up test.
mysql-test/suite/pbxt/r/cast.result:
  Updated results after better cast warnings
mysql-test/suite/pbxt/r/func_str.result:
  Updated results after better cast warnings
mysql-test/suite/pbxt/r/type_newdecimal.result:
  Updated results after better cast warnings
mysql-test/suite/rpl/r/rpl_innodb_bug28430.result:
  Added begin...commit to speed up test.
mysql-test/suite/rpl/t/rpl_innodb_bug28430.test:
  Added begin...commit to speed up test.
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_innodb.result:
  More warnings
mysql-test/suite/vcol/r/vcol_supported_sql_funcs_myisam.result:
  More warnings
mysql-test/t/cast.test:
  A lot of new cast() tests
mysql-test/t/strict.test:
  Added new test
mysys/CMakeLists.txt:
  Added ma_dyncol.c
mysys/Makefile.am:
  Added ma_dyncol.c
mysys/string.c:
  Added dynstr_reassociate() to move a buffer from dynamic_strings to some other allocator
sql-common/my_time.c:
  Added 'fuzzydate' flag to str_to_time()
  Added support for microseconds to my_time_to_str() and my_datetime_to_str()
  Reset second_parts in number_to_datetime()
  Added double_to_datetime()
sql/field.cc:
  Added double_to_longlong() and truncate_double() to simplify and reuse code
sql/field.h:
  New prototypes
sql/item.cc:
  Changed Item::get_date(MYSQL_TIME *ltime,uint fuzzydate) to be aware of type of argument.
  (Needed to make it microsecond safe and get better warnings).
  Updated call to str_to_time_with_warn()
sql/item.h:
  Added struct st_dyncall_create_def used by dynamic columns
  Added virtual bool dynamic_result() to tell if type of argument may change over calls.
sql/item_cmpfunc.cc:
  Added Item_func_dyncol_exists()
sql/item_cmpfunc.h:
  Added class Item_func_dyncol_exists
sql/item_create.cc:
  Added get_length_and_scale() to simplify other functions
  Simplified and extended create_func_cast()
  Added support for cast(X as double(X,Y))
  Added functions to create dynamic column functions.
sql/item_create.h:
  Added prototypes
sql/item_func.cc:
  Extended cast functions Item_func_signed() and Item_func_unsigned() to work with dynamic types
  Added Item_double_typecast()
sql/item_func.h:
  Added class Item_double_typecast()
sql/item_strfunc.cc:
  Added functions for COLUMN_CREATE(), COLUMN_ADD(), COLUMN_GET() and COLUMN_LIST()
sql/item_strfunc.h:
  Added classes for COLUMN_CREATE(), COLUMN_ADD(), COLUMN_GET() and COLUMN_LIST()
sql/item_timefunc.cc:
  Added flag argument to str_to_time_with_warn()
  Updated Item_char_typecast() to handle result type that may change between calls (for dynamic columns)
  Added Item_time_typecast::get_date() to ensure that we cast a datetime to time properly.
sql/item_timefunc.h:
  Added get_date() to Item_time_typecast() to allow proper results for casting time to datetime
sql/lex.h:
  Added new SQL function names
sql/my_decimal.cc:
  Added 'const' to some arguments.
  Better error message in case of errors (we now print out the wrong value)
  Added my_decimal2int()
sql/my_decimal.h:
  Moved some constants to my_decimal_limits.h
  Updated prototypes.
  Made my_decimal2int() a function as it's rather long (no reason to have it inline)
  Added decimal2my_decimal() function.
sql/mysql_priv.h:
  Prototypes for new functions
sql/share/errmsg.txt:
  New error messages for wrong casts and dynamic columns
sql/sql_acl.cc:
  Fixed indentation
sql/sql_base.cc:
  Added dynamic_column_error_message()
sql/sql_string.h:
  Added reassociate() to move a buffer to be owned by String object.
sql/sql_yacc.yy:
  Added syntax for COLUMN_ functions.
sql/time.cc:
  Updated str_to_datetime_with_warn() flag argument to same type as other functions
  Added conversion flag to str_to_time_with_warn() (Similar to all datetime functions)
  Added conversion functions with warnings: double_to_datetime_with_warn() and decimal_to_datetime_with_warn()
strings/decimal.c:
  Added 'const' to arguments for some functions.
unittest/mysys/Makefile.am:
  Added test for dynamic columns code
2011-05-08 13:24:06 +03:00
Michael Widenius
1be5462d59 Merge with MariaDB 5.1 2011-05-03 19:10:10 +03:00
Michael Widenius
e415ba0fb2 Merge with MySQL 5.1.57/58
Moved some BSD string functions from Unireg
2011-05-02 20:58:45 +03:00
unknown
ec23949158 Fix LP BUG#715738
Analysis:
A query with implicit grouping is one with aggregate functions and
no GROUP BY clause. MariaDB inherits from MySQL an SQL extenstion
that allows mixing aggregate functions with non-aggregate fields.
If a query with such mixed select clause produces an empty result
set, the meaning of aggregate functions is well defined - either
NULL (MIN, MAX, etc.), or 0 (count(*)). However the non-aggregated
fields must also have some value, and the only reasonable value in
the case of empty result is NULL.

The cause of the many wrong results was that if a field is declared
as non-nullable (e.g. because it is a PK or NOT NULL), the semantic
analysis and the optimization phases treat this field as non-nullable,
and generate all related query plan elements based on this assumption.

Later during execution, these incorrectly configured/generated query
plan elements result in a wrong result because the selected fields
are not null due to the not-null assumption during optimization.

Solution:
Detect before the context analysys phase that a query uses implicit
grouping with mixed aggregates/non-aggregates, and set all fields
as nullable. The parser already walks the SELECT clause, and
already sets Item::with_sum_func for Items that reference aggreagate
functions. The patch adds a symmetric Item::with_field so that all
Items that reference an Item_field are marked during their
construction at parse time in the same way as with aggregate function
use.
2011-03-24 16:34:06 +02:00
Alexander Barkov
a1e9be8e8b Bug 11766519 - 59648: MY_STRTOLL10_MB2: ASSERTION `(*ENDPTR - S) % 2 == 0' FAILED.
Part 2. Function QUOTE() was not multi-byte safe.

  @ mysql-test/r/ctype_ucs.result
  @ mysql-test/t/ctype_ucs.test
  Adding tests

  @ sql/item_strfunc.cc
  Fixing Item_func_quote::val_str to be multi-byte safe.

  @ sql/item_strfunc.h
  Multiple size needed for quote characters to mbmaxlen
2011-03-03 18:39:26 +03:00
Alexander Barkov
1bc5e76efb BUG#11766519 (bug#59648): MY_STRTOLL10_MB2: ASSERTION `(*ENDPTR - S) % 2 == 0' FAILED
Problem: wrong character set pointer was passed to my_strtoll10_mb2,
which led to DBUG_ASSERT failure in some cases.

  @ mysql-test/r/func_encrypt_ucs2.result
  @ mysql-test/t/func_encrypt_ucs2.test
  @ mysql-test/r/ctype_ucs.result
  @ mysql-test/t/ctype_ucs.test
  Adding tests

  @ sql/item_func.cc
  "cs" initialization was wrong (res does not necessarily point to &str_value)

  @ sql/item_strfunc.cc
  Item_func_dec_encrypt::val_str() and Item_func_des_descrypt::val_str()
  did not set character set for tmp_value (the returned value),
  so the old value, which was previously copied from args[1]->val_str(),
  was incorrectly returned with tmp_value.
2011-03-03 15:04:04 +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
58bb0769bd Merge with MySQL 5.1.55
- Fixed some issues with partitions and connection_string, which also fixed lp:716890 "Pre- and post-recovery crash in Aria"
- Fixed wrong assert in Aria

Now need to merge with latest xtradb before pushing 

sql/ha_partition.cc:
  Ensure that m_ordered_rec_buffer is not freed before close.
sql/mysqld.cc:
  Changed to use opt_stack_trace instead of opt_pstack.
  Removed references to pstack
sql/partition_element.h:
  Ensure that connect_string is initialized
storage/maria/ma_key_recover.c:
  Fixed wrong assert
2011-02-20 18:51:43 +02:00
Alexander Barkov
6665ca25af Bug#58371 Assertion failed: !s.uses_buffer_owned_by(this) with format string function
Introduced by the fix for bug#44766.

Problem: it's not correct to use args[0]->str_value as a buffer,
because args[0] may need this buffer for its own purposes.

Fix: adding a new class member tmp_value to use as return value.

  @ mysql-test/r/ctype_many.result
  @ mysql-test/t/ctype_many.test
  Adding tests

  @ sql/item_strfunc.cc
  Changing code into traditional style:
  use "str" as a buffer for the argument and tmp_value for the result value.

  @ sql/item_strfunc.h
  Adding tmp_value
2011-01-17 15:11:33 +03:00
Martin Hansson
716b64cdb0 Bug#58165: "my_empty_string" gets modified and causes LOAD DATA to fail and
other crashes

Some string manipulating SQL functions use a shared string object intended to
contain an immutable empty string. This object was used by the SQL function
SUBSTRING_INDEX() to return an empty string when one argument was of the wrong
datatype. If the string object was then modified by the sql function INSERT(),
undefined behavior ensued.

Fixed by instead modifying the string object representing the function's
result value whenever string manipulating SQL functions return an empty
string.

Relevant code has also been documented.
2011-01-13 08:57:15 +01:00
Michael Widenius
1e5061fe3b merge with 5.1 2010-11-30 23:11:03 +02:00
Michael Widenius
1a6373e8e2 Merge with MySQL 5.1.53
Open issues:
- A better fix for #57688; Igor is working on this
- Test failure in index_merge_innodb.test ; Igor promised to look at this
- Some Innodb tests fails (need to merge with latest xtradb) ; Kristian promised to look at this.
 - Failing tests: innodb_plugin.innodb_bug56143 innodb_plugin.innodb_bug56632 innodb_plugin.innodb_bug56680 innodb_plugin.innodb_bug57255 
- Werror is disabled;  Should be enabled after merge with xtradb.
2010-11-25 00:57:34 +02:00
Alexander Barkov
aa668865e2 Bug#57257 Replace(ExtractValue(...)) causes MySQL crash
Bug#57820 extractvalue crashes

Problem: ExtractValue and Replace crashed in some cases
due to invalid handling of empty and NULL arguments.

Per file comments:

  @mysql-test/r/ctype_ujis.result
  @mysql-test/r/xml.result
  @mysql-test/t/ctype_ujis.test
  @mysql-test/t/xml.test
  Adding tests

  @sql/item_strfunc.cc
  Make sure Item_func_replace::val_str safely handles empty strings.

  @sql/item_xmlfunc.cc
  set null_value if nodeset_func returned NULL,
  which is possible when the second argument is an
  unset user variable.
2010-11-11 13:25:23 +03:00
Ramil Kalimullin
b001a5224d Fix for bug#57283: inet_ntoa() crashes
Problem: some call of INET_NTOA() function may lead 
to a crash due to missing its character set initialization.

Fix: explicitly set the character set.


mysql-test/r/func_misc.result:
  Fix for bug#57283: inet_ntoa() crashes
    - test result.
mysql-test/t/func_misc.test:
  Fix for bug#57283: inet_ntoa() crashes
    - test case.
sql/item_strfunc.cc:
  Fix for bug#57283: inet_ntoa() crashes
    - explicitly set buffer's character set.
2010-10-12 23:28:03 +04:00
Ramil Kalimullin
42550e21e8 Fix for bug#57272: crash in rpad() when using utf8
Problem: if multibyte and binary string arguments passed to 
RPAD(), LPAD() or INSERT() functions, they might return 
wrong results or even lead to a server crash due to missed
character set convertion.

Fix: perform the convertion if necessary.


mysql-test/r/ctype_utf8.result:
  Fix for bug#57272: crash in rpad() when using utf8
    - test result.
mysql-test/t/ctype_utf8.test:
  Fix for bug#57272: crash in rpad() when using utf8
    - test case.
sql/item_strfunc.cc:
  Fix for bug#57272: crash in rpad() when using utf8
    - convert multibyte argument's character set to binary in case of
  FUNCTION(MULTIBYTE_ARG, .., BINARY_ARG,..) for RPAD(), LPAD() and 
  INSERT() functions.
2010-10-12 23:25:40 +04:00
Michael Widenius
165eb1186c Added extra argument to longlong2str() to make it have same prototype is int2str()
Changed to use longlong10_to_str() instead of longlong2str() when base is 10 or -10 as former is much faster than later
Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit.

client/mysqltest.cc:
  longlong2str() -> longlong10_to_str()
include/m_string.h:
  Added extra argument to longlong2str() to make it have same prototype is int2str()
mysys/charset.c:
  Fixed compiler warning
mysys/mf_soundex.c:
  Fixed compiler warning
mysys/my_getopt.c:
  longlong2str() -> longlong10_to_str()
sql/create_options.cc:
  Fixed compiler warning
sql/item_strfunc.cc:
  Added extra argument to longlong2str
sql/opt_range.cc:
  longlong2str() -> longlong10_to_str()
sql/partition_info.cc:
  longlong2str() -> longlong10_to_str()
sql/slave.cc:
  longlong2str() -> longlong10_to_str()
sql/sql_bitmap.h:
  Added extra argument to longlong2str
sql/sql_partition.cc:
  Added extra argument to longlong2str
sql/sql_select.cc:
  longlong2str() -> longlong10_to_str()
sql/sql_show.cc:
  Added extra argument to longlong2str
storage/innodb_plugin/handler/ha_innodb.cc:
  Update to new parameters for longlong2str()
storage/maria/ma_dbug.c:
  longlong2str() -> longlong10_to_str()
storage/maria/maria_chk.c:
  Added extra argument to longlong2str
storage/myisam/mi_dbug.c:
  longlong2str() -> longlong10_to_str()
storage/myisam/myisamchk.c:
  Added extra argument to longlong2str
storage/xtradb/handler/ha_innodb.cc:
  Update to new parameters for longlong2str()
strings/longlong2str.c:
  Added extra argument to longlong2str() to make it have same prototype is int2str()
strings/my_vsnprintf.c:
  Changed my_vsnprintf() to use longlong2str instead of int2str() to get rid of warnings and to get support for long pointers even when long is 32 bit.
  Added cast to get rid of compiler warnings
2010-08-07 15:27:23 +03: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
Kristofer Pettersson
5dd5d70506 Bug#50373 --secure-file-priv=""
Iterative patch improvement. Previously committed patch
caused wrong result on Windows. The previous patch also
broke secure_file_priv for symlinks since not all file
paths which must be compared against this variable are
normalized using the same norm.

The server variable opt_secure_file_priv wasn't
normalized properly and caused the operations
LOAD DATA INFILE .. INTO TABLE ..
and
SELECT load_file(..)
to do different interpretations of the 
--secure-file-priv option.
     
The patch moves code to the server initialization
routines so that the path always is normalized
once and only once.
      
It was also intended that setting the option
to an empty string should be equal to 
lifting all previously set restrictions. This
is also fixed by this patch.


mysql-test/r/loaddata.result:
  * Removed test code which will currently break the much used --mem feature of mtr.
mysql-test/t/loaddata.test:
  * Removed test code which will currently break the much used --mem feature of mtr.
sql/item_strfunc.cc:
  * Replaced string comparing code on opt_secure_file_priv with an interface which guarantees that both file paths are normalized using the same norm on all platforms.
sql/mysql_priv.h:
  * Added signature for is_secure_file_path()
sql/mysqld.cc:
  * New function for checking if a path compatible with the secure path restriction.
  * Added initialization of the opt_secure_file_priv variable.
sql/sql_class.cc:
  * Replaced string comparing code on opt_secure_file_priv with an interface which guarantees that both file paths are normalized using the same norm on all platforms.
sql/sql_load.cc:
  * Replaced string comparing code on opt_secure_file_priv with an interface which guarantees that both file paths are normalized using the same norm on all platforms.
2010-05-03 18:14:39 +02:00
unknown
b1e00b6be8 Merge MySQL 5.1.46 into MariaDB.
Still two test failures to be solved: main.myisam and main.subselect.
2010-04-28 14:52:24 +02:00
Gleb Shchepa
e2a546aef4 Bug #40625: Concat fails on DOUBLE values in a Stored
Procedure, while DECIMAL works

Selecting of the CONCAT(...<SP variable>...) result into
a user variable may return wrong data.


Item_func_concat::val_str contains a number of memory
allocation-saving tricks. One of them concatenates
strings inplace inserting the value of one string
at the beginning of the other string. However,
this trick didn't care about strings those points
to the same data buffer: this is possible when
a CONCAT() parameter is a stored procedure variable -
Item_sp_variable::val_str() uses the intermediate
Item_sp_variable::str_value field, where it may
store a reference to an external buffer.


The Item_func_concat::val_str function has been
modified to take into account val_str functions
(such as Item_sp_variable::val_str) that return
a pointer to an internal Item member variable
that may reference to a buffer provided.


mysql-test/r/func_concat.result:
  Test case for the bug #40625.
mysql-test/t/func_concat.test:
  Test case for the bug #40625.
sql/item_strfunc.cc:
  Bug #40625: Concat fails on DOUBLE values in a Stored
              Procedure, while DECIMAL works
  
  The Item_func_concat::val_str function has been
  modified to take into account val_str functions
  (such as Item_sp_variable::val_str) that return
  a pointer to an internal Item member variable
  that may reference to a buffer provided.
2010-04-03 00:30:22 +04:00
unknown
4bf849c23c Merge MySQL 5.1.44 into MariaDB. 2010-03-04 09:03:07 +01:00
Davi Arnaut
c3a73a8f6d Fix for compiler warnings:
Rename method as to not hide a base.
Reorder attributes initialization.
Remove unused variable.
Rework code to silence a warning due to assignment used as truth value.


sql/item_strfunc.cc:
  Rename method as to not hide a base.
sql/item_strfunc.h:
  Rename method as to not hide a base.
sql/log_event.cc:
  Reorder attributes initialization.
sql/rpl_injector.cc:
  Rework code to silence a warning due to assignment used as truth value.
sql/rpl_record.cc:
  Remove unused variable.
sql/sql_db.cc:
  Rework code to silence a warning due to assignment used as truth value.
sql/sql_parse.cc:
  Rework code to silence a warning due to assignment used as truth value.
sql/sql_table.cc:
  Rework code to silence a warning due to assignment used as truth value.
2010-01-28 19:51:40 -02:00
Davi Arnaut
7920e89a47 Bug#49491: Much overhead for MD5() and SHA1() on short strings
MySQL's hash functions MD5 and SHA relied on the somewhat slow 
sprintf function to convert the digests to hex representations.
This patch replaces the sprintf with a specific and inline hex
conversion function.

Patch contributed by Jan Steemann.

sql/item_strfunc.cc:
  Add a hex conversion function.
2010-01-26 15:05:19 -02:00
Michael Widenius
d8ecbbe634 Merge with MySQL 5.1.42
- Marked a couple of tests with --big
- Fixed xtradb/handler/ha_innodb.cc to call explain_filename()

storage/xtradb/handler/ha_innodb.cc:
  Call explain_filename() to get proper names for partitioned tables
2010-01-15 17:27:55 +02:00
Gleb Shchepa
71fd38e488 Bug #50096: CONCAT_WS inside procedure returning wrong data
Selecting of the CONCAT_WS(...<PS parameter>...) result into
a user variable may return wrong data.

Item_func_concat_ws::val_str contains a number of memory
allocation-saving optimization tricks. After the fix
for bug 46815 the control flow has been changed to a
branch that is commented as "This is quite uncommon!":
one of places where we are trying to concatenate
strings inplace. However, that "uncommon" place
didn't care about PS parameters, that have another
trick in Item_sp_variable::val_str(): they use the
intermediate Item_sp_variable::str_value field,
where they may store a reference to an external
argument's buffer.

The Item_func_concat_ws::val_str function has been
modified to take into account val_str functions
(such as Item_sp_variable::val_str) that return a
pointer to an internal Item member variable that
may reference to a buffer provided.


mysql-test/r/func_concat.result:
  Added test case for bug #50096.
mysql-test/t/func_concat.test:
  Added test case for bug #50096.
sql/item_strfunc.cc:
  Bug #50096: CONCAT_WS inside procedure returning wrong data
  
  The Item_func_concat_ws::val_str function has been
  modified to take into account val_str functions
  (such as Item_sp_variable::val_str) that return a
  pointer to an internal Item member variable that
  may reference to a buffer provided.
2010-01-13 08:16:36 +04:00
Davi Arnaut
e53ecf2dc2 Bug#49141: Encode function is significantly slower in 5.1 compared to 5.0
The problem was that the multiple evaluations of a ENCODE or
DECODE function within a single statement caused the random
generator to be reinitialized at each evaluation, even though
the parameters were constants.

The solution is to initialize the random generator only once
if the password (seed) parameter is constant.

This patch borrows code and ideas from Georgi Kodinov's patch.

mysql-test/r/func_str.result:
  Add test case result.
mysql-test/r/ps.result:
  Add test case result.
mysql-test/t/func_str.test:
  Add test case for Bug#49141
mysql-test/t/ps.test:
  Add test case for Bug#49141
sql/item_strfunc.cc:
  Move seed generation code to a separate method.
  Seed only once if the password (seed) argument
  is constant.
  Remove duplicated code and use a transform method
  to apply encoding or decoding.
sql/item_strfunc.h:
  Add parameter to signal whether the PRNG is already seeded.
  Introduce transform method.
  Combine val_str methods.
sql/sql_crypt.cc:
  Remove method.
sql/sql_crypt.h:
  Seed is supplied as two long integers.
2009-12-04 13:36:58 -02:00
Sven Sandberg
2f78abd21b BUG#47995: Mark system functions as unsafe
Problem: Some system functions that could return different values on
master and slave were not marked unsafe. In particular:
 GET_LOCK
 IS_FREE_LOCK
 IS_USED_LOCK
 MASTER_POS_WAIT
 RELEASE_LOCK
 SLEEP
 SYSDATE
 VERSION
Fix: Mark these functions unsafe.


mysql-test/extra/rpl_tests/rpl_stm_000001.test:
  - The test does not work in mixed mode any more, since it tries to
    simulate an error in the sql thread in a query that uses get_lock.
    Since get_lock now causes the query to be logged in row format,
    the error didn't happen. Hence, we now force statement mode.
  - Warnings must be disabled when the unsafe query is issued.
  - Replaced some save_master_pos+connection slave+sync_with_master
    by sync_slave_with_master.
mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result:
  updated result file
mysql-test/suite/binlog/r/binlog_stm_row.result:
  updated result file
mysql-test/suite/binlog/r/binlog_unsafe.result:
  updated result file
mysql-test/suite/binlog/t/binlog_killed.test:
  binlog_killed only works in statement format now, since
  it switches to row mode in mixed mode.
mysql-test/suite/binlog/t/binlog_stm_mix_innodb_myisam.test:
  suppress warnings for unsafe statements
mysql-test/suite/binlog/t/binlog_stm_row.test:
  - Suppress warnings in test that causes warnings.
  - The test sets binlog format explicitly, so no need to execute it
    twice.
mysql-test/suite/binlog/t/binlog_unsafe.test:
  Added test for all unsafe system functions. This test also includes
  system functions that were unsafe prior to BUG#47995.
mysql-test/suite/rpl/r/rpl_err_ignoredtable.result:
  updated result file
mysql-test/suite/rpl/r/rpl_get_lock.result:
  updated result file
mysql-test/suite/rpl/r/rpl_nondeterministic_functions.result:
  new result file
mysql-test/suite/rpl/r/rpl_stm_000001.result:
  updated result file
mysql-test/suite/rpl/r/rpl_trigger.result:
  updated result file
mysql-test/suite/rpl/t/rpl_err_ignoredtable.test:
  - suppress warnings for unsafe statement
  - replaced save_master_pos+connection slave+sync_with_master
    with sync_slave_with_master
mysql-test/suite/rpl/t/rpl_get_lock.test:
  update test case that causes new warnings
mysql-test/suite/rpl/t/rpl_nondeterministic_functions.test:
  Added new test case for nondeterministic functions.
mysql-test/suite/rpl/t/rpl_trigger.test:
  update test case that causes new warnings
sql/item_create.cc:
  Marked some system functions unsafe.
sql/item_strfunc.cc:
  Clarified comment related to this bug.
sql/sql_yacc.yy:
  Marked sysdate unsafe.
2009-11-18 15:50:31 +01:00
unknown
a962160eec Merge with MySQL 5.1, with following additions:
- Moved some code from innodb_plugin to xtradb, to ensure that all tests runs
- Did changes in pbxt and maria storage engines becasue of changes in thd->query
- Reverted wrong code in sql_table.cc for how ROW_FORMAT is used.

This is a re-commit of Monty's merge to eliminate an extra commit from
MySQL-5.1.42 that was accidentally included in the merge.

This is a merge of the MySQL 5.1.41 clone-off (clone-5.1.41-build). In
case there are any extra changes done before final MySQL 5.1.41
release, these will need to be merged later before MariaDB 5.1.41
release.
2009-11-16 21:49:51 +01:00
Sergey Glukhov
0412a7c753 5.0-bugteam->5.1-bugteam merge 2009-09-10 15:30:03 +05:00
Sergey Glukhov
10406ae658 Bug#46815 CONCAT_WS returning wrong data
The problem is that argument buffer can be used as result buffer
and it leads to argument value change.
The fix is to use 'old buffer' as result buffer only
if first argument is not constant item.


mysql-test/r/func_str.result:
  test result
mysql-test/t/func_str.test:
  test case
sql/item_strfunc.cc:
  The problem is that argument buffer can be used as result buffer
  and it leads to argument value change.
  The fix is to use 'old buffer' as result buffer only
  if first argument is not constant item.
2009-09-10 15:24:07 +05:00
Sergey Petrunya
29f0dcb563 Merge MySQL->MariaDB
* Finished Monty and Jani's merge
* Some InnoDB tests still fail (because it's old xtradb code run against
  newer testsuite). They are expected to go after mergning with the latest
  xtradb.
2009-09-08 00:50:10 +04:00
Martin Hansson
aa8677bc32 Bug#45168: assertion with convert() and empty set value
The assertion in String::copy was added in order to avoid
valgrind errors when the destination was the same as the source.
Eased restriction to allow for the case when str == NULL.


mysql-test/r/func_set.result:
  Bug#45168: Test result
mysql-test/t/func_set.test:
  Bug#45168: Test case
sql/item_strfunc.cc:
  Bug#45168: Code cleanup and grammar correction in comment
sql/sql_string.cc:
  Bug#45168: Fix
2009-06-16 16:36:15 +02:00
Alexey Kopytov
aef45b47a0 Automerge. 2009-06-01 16:43:16 +04:00
Alexey Kopytov
47b334a642 Automerge. 2009-06-01 16:42:24 +04:00
Alexey Kopytov
7561bc9212 Manual merge. 2009-06-01 16:00:38 +04:00
Alexey Kopytov
1b8322c3c6 Bug #44767: invalid memory reads in password() and
old_password() functions   
The PASSWORD() and OLD_PASSWORD() functions could lead to   
memory reads outside of an internal buffer when used with BLOB   
arguments.   
  
String::c_ptr() assumes there is at least one extra byte  
in the internally allocated buffer when adding the trailing  
'\0'.  This, however, may not be the case when a String object  
was initialized with externally allocated buffer.  
  
The bug was fixed by adding an additional "length" argument to  
make_scrambled_password_323() and make_scrambled_password() in  
order to avoid String::c_ptr() calls for  
PASSWORD()/OLD_PASSWORD().  
  
However, since the make_scrambled_password[_323] functions are  
a part of the client library ABI, the functions with the new  
interfaces were implemented with the 'my_' prefix in their  
names, with the old functions changed to be wrappers around  
the new ones to maintain interface compatibility.  

mysql-test/r/func_crypt.result:
  Added a test case for bug #44767.
mysql-test/t/func_crypt.test:
  Added a test case for bug #44767.
sql/item_strfunc.cc:
  Use the new my_make_scrambled_password*() to avoid 
  String::c_ptr().
sql/item_strfunc.h:
  Changed Item_func[_old]_password::alloc() interfaces so that
  we can use the new my_make_scrambled_password*() functions.
sql/mysql_priv.h:
  Added declarations for the new my_make_scrambled_password*() 
  functions.
sql/password.c:
  Added new my_make_scrambled_password*() functions with an
  additional "length" argument. Changed ones to be wrappers
  around the new ones to maintain interface compatibility.
sql/sql_yacc.yy:
  Utilize the new password hashing functions with additional length
  argument.
2009-05-27 14:20:57 +04:00
unknown
48083d73d3 After-merge fixes for problems seen in buildbot after merging MySQL-5.1.35.
- Version number.
 - Valgrind false alarms in libz.
 - New variant of suppression for Valgrind warning in dlclose().
 - Fix double free() in plugin init error case.

configure.in:
  Fix version number. We should reset the maria variant back to `1' when the MySQL version
  number increases.
include/my_sys.h:
  Fix false alarms in Valgrind for zlib.
  
  Apply same fix as for archive storage handler also to the cases of compression in the
  client protocol, and to the compression SQL function.
mysql-test/valgrind.supp:
  A new variant of the dlclose() suppression is needed now.
mysys/my_compress.c:
  Fix false alarms in Valgrind for zlib.
  
  Apply same fix as for archive storage handler also to the cases of compression in the
  client protocol, and to the compression SQL function.
sql/handler.cc:
  Fix a double free() in error case for plugin initialisation.
sql/item_strfunc.cc:
  Fix false alarms in Valgrind for zlib.
  
  Apply same fix as for archive storage handler also to the cases of compression in the
  client protocol, and to the compression SQL function.
2009-05-22 14:38:50 +02:00
Alexey Kopytov
1bf8e86ab4 Automerge. 2009-05-21 16:16:17 +04:00
Alexey Kopytov
958e896d8f Automerge. 2009-05-21 16:08:16 +04:00
Ramil Kalimullin
985df4dcdc Fix for bug#44743: Join in combination with concat does not always work
bug#44766: valgrind error when using convert() in a subquery

Problem: input and output buffers may be the same 
converting a string to some charset. 
That may lead to wrong results/valgrind warnings.  

Fix: use different buffers.


mysql-test/r/cast.result:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - test result.
mysql-test/r/func_concat.result:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - test result.
mysql-test/t/cast.test:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - test case.
mysql-test/t/func_concat.test:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - test case.
sql/item.cc:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - comment added.
sql/item_strfunc.cc:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - '&args[0]->str_value' used as a parameter of args[0]->val_str(),
      as 'str' may be equal to 'str_value' which we use as the output buffer
      converting strings.
sql/sql_string.cc:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - input and output buffers must NOT be the same.
2009-05-21 13:06:43 +05:00
Alexey Kopytov
0b62b7f26d Bug #44796: valgrind: too many my_longlong10_to_str_8bit
warnings after uncompressed_length 
 
UNCOMPRESSED_LENGTH() did not validate its argument. In 
particular, if the argument length was less than 4 bytes, 
an uninitialized memory value was returned as a result. 
 
Since the result of COMPRESS() is either an empty string or 
a 4-byte length prefix followed by compressed data, the bug was 
fixed by ensuring that the argument of UNCOMPRESSED_LENGTH() is 
either an empty string or contains at least 5 bytes (as done in 
UNCOMPRESS()). This is the best we can do to validate input 
without decompressing. 

mysql-test/r/func_compress.result:
  Added a test case for bug #44796.
mysql-test/t/func_compress.test:
  Added a test case for bug #44796.
sql/item_strfunc.cc:
  Make sure that the argument of UNCOMPRESSED_LENGTH() contains 
  at least 5 bytes (as done in UNCOMPRESS()).
2009-05-20 12:30:06 +04:00
Ramil Kalimullin
8b9084eff4 Fix for bug#44774: load_file function produces valgrind warnings
Problem: using LOAD_FILE() in some cases we pass a file name string
without a trailing '\0' to fn_format() which relies on that however.
That may lead to valgrind warnings.

Fix: add a trailing '\0' to the file name passed to fn_format().


mysql-test/r/func_str.result:
  Fix for bug#44774: load_file function produces valgrind warnings
    - test result.
mysql-test/t/func_str.test:
  Fix for bug#44774: load_file function produces valgrind warnings
    - test case.
sql/item_strfunc.cc:
  Fix for bug#44774: load_file function produces valgrind warnings
    - passing a file name to fn_format(), file_name->c_ptr() replaced
      with file_name->c_ptr_safe() to ensure we have a trailing '\0'.
2009-05-12 13:18:27 +05:00
Ramil Kalimullin
d0128f5ec0 Auto-merge. 2009-05-13 23:39:35 +05:00