Commit graph

638 commits

Author SHA1 Message Date
unknown
6e8c4d696a MDEV-452 Add full support for auto-initialized/updated timestamp and datetime
Post-review changes according to Monty's review from 28/11/2012.
2012-12-13 22:56:03 +02:00
unknown
bc4a456758 MDEV-452 Add full support for auto-initialized/updated timestamp and datetime
Generalized support for auto-updated and/or auto-initialized timestamp
and datetime columns. This patch is a reimplementation of MySQL's
"WL#5874: CURRENT_TIMESTAMP as DEFAULT for DATETIME columns". In order to
ease future merges, this implementation reused few function and variable
names from MySQL's patch, however the implementation is quite different.

TODO:
The only unresolved problem in this patch is the semantics of LOAD DATA for
TIMESTAMP and DATETIME columns in the cases when there are missing or NULL
columns. I couldn't fully comprehend the logic behind MySQL's behavior and
its relationship with their own documentation, so I left the results to be
more consistent with all other LOAD cases.

The problematic test cases can be seen by running the test file function_defaults,
and observing the test case differences. Those were left on purpose for discussion.
2012-10-17 15:43:56 +03:00
Vladislav Vaintroub
072097174c fix compile error, when building with oqgraph 2012-06-25 18:17:24 +02:00
Igor Babaev
2954ed1ec9 Merge 5.3->5.5. 2012-06-24 09:10:11 -07:00
Igor Babaev
20f3f4a273 Merge 5.2->5.3 2012-06-23 15:00:05 -07:00
Igor Babaev
0c69f22032 Fixed bug mdev-354.
Virtual columns of ENUM and SET data types were not supported properly
in the original patch that introduced virtual columns into MariaDB 5.2.
The problem was that for any  virtual column the patch used the 
interval_id field of the definition of the column in the frm file as
a reference to the virtual column expression.
The fix stores the optional interval_id of the virtual column in the
extended header of the virtual column expression.
2012-06-18 22:32:17 -07:00
Sergei Golubchik
0522307ed1 mysql-5.5 merge 2012-06-14 20:05:31 +02:00
Sergei Golubchik
431e042b5d c 2012-05-21 15:30:25 +02:00
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
Igor Babaev
5d954e7cd0 Merge 5.3->5.5 2012-03-17 01:26:58 -07:00
Michael Widenius
6f06cef02b Fixed bug lp:917689 "Archive table corruption crashing MariaDB signal 11"
Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
Change ha_archive::unpack_row() to detect wrong field lengths.
Replication code changed to detect wrong field information in events.


mysql-test/r/archive.result:
  dded test case for lp:917689
sql/field.cc:
  Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
  Removed not used 'unpack_key' functions.
sql/field.h:
  Added 'from_end' as extra parameter to Field::unpack() to detect wrong from data.
  Removed not used 'unpack_key' functions.
  Removed some not needed unpack() functions.
sql/filesort.cc:
  Added buffer end parameter to unpack_addon_fields()
sql/log_event.h:
  Added end of buffer argument to unpack_row()
sql/log_event_old.cc:
  Added end of buffer argument to unpack_row()
sql/log_event_old.h:
  Added end of buffer argument to unpack_row()
sql/records.cc:
  Added buffer end parameter to unpack_addon_fields()
sql/rpl_record.cc:
  Added end of buffer argument to unpack_row()
  Added detection of wrong field information in events
sql/rpl_record.h:
  Added end of buffer argument to unpack_row()
sql/rpl_record_old.cc:
  Added end of buffer argument to unpack_row()
  Added detection of wrong field information in events
sql/rpl_record_old.h:
  Added end of buffer argument to unpack_row()
sql/table.h:
  Added buffer end parameter to unpack()
storage/archive/ha_archive.cc:
  Change ha_archive::unpack_row() to detect wrong field lengths.
  This fixes lp:917689
2012-03-13 16:38:43 +02:00
Sergei Golubchik
4f435bddfd 5.3 merge 2012-01-13 15:50:02 +01:00
Michael Widenius
6d4224a31c Merge with 5.2.
no_error handling for select (used by INSERT ... SELECT) still needs to be fixed, but I will do that in a separate commit
2011-12-11 11:34:44 +02:00
Michael Widenius
6920457142 Merge with MariaDB 5.1 2011-11-24 18:48:58 +02:00
Michael Widenius
7b368e3810 Merge with MySQL 5.1.60 2011-11-23 19:32:14 +02:00
Michael Widenius
a8d03ab235 Initail merge with MySQL 5.1 (XtraDB still needs to be merged)
Fixed up copyright messages.
2011-11-21 19:13:14 +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
Sergei Golubchik
6edd76785c merge 2011-11-03 23:39:53 +01:00
Sergei Golubchik
0e007344ea mysql-5.5.18 merge 2011-11-03 19:17:05 +01:00
Sergei Golubchik
90b43902b0 compilation warnings on Windows 2011-11-02 12:55:46 +01:00
Sergei Golubchik
76f0b94bb0 merge with 5.3
sql/sql_insert.cc:
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
  ******
  CREATE ... IF NOT EXISTS may do nothing, but
  it is still not a failure. don't forget to my_ok it.
sql/sql_table.cc:
  small cleanup
  ******
  small cleanup
2011-10-19 21:45:18 +02:00
Kent Boortz
027b5f1ed4 Updated/added copyright headers 2011-07-03 17:47:37 +02:00
Sergei Golubchik
9809f05199 5.5-merge 2011-07-02 22:08:51 +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
Igor Babaev
078b59f5bc Merge of mwl #106 into 5.3. 2011-06-15 21:48:38 -07:00
Sergei Golubchik
49874ff827 more buildbot fixes 2011-06-10 21:15:13 +02:00
Sergei Golubchik
f1a5c49c4e various fixes for buildbot failures 2011-06-10 15:42:55 +02:00
Sergei Golubchik
fdfeb4bea3 small optimization in Field_time_hires.
Fix Field_time_hires::reset()
2011-06-09 18:06:29 +02:00
Sergei Golubchik
c3f665dc66 bugfixes:
microsecond(TIME)
  alter table datetime<->datetime(6)
  max(TIME), mix(TIME) 

mysql-test/t/func_if.test:
  fix the test case of avoid overflow
sql/field.cc:
  don't use make_date() and make_time()
sql/field.h:
  correct eq_def() for temporal fields
sql/item.cc:
  move datetime caching from Item_cache_int
  to Item_cache_temporal
sql/item.h:
  move datetime caching from Item_cache_int
  to Item_cache_temporal
sql/item_func.cc:
  use existing helper methods, don't duplicate
sql/item_sum.cc:
  argument cache must use argument's cmp_type, not result_type.
sql/item_timefunc.cc:
  use existing methods, don't tuplicate.
  remove unused function.
  fix micorseconds() to support TIME argument
sql/mysql_priv.h:
  dead code
sql/time.cc:
  dead code
2011-06-09 17:23:39 +02:00
Sergei Golubchik
9b98cae4cc merge with 5.1-micro 2011-06-07 18:13:02 +02:00
Sergei Golubchik
4d128777dd revert a suggested "optimization" that introduced a bug
compilation error in mysys/my_getsystime.c fixed
some redundant code removed
sec_to_time, time_to_sec, from_unixtime, unix_timestamp, @@timestamp now
  use decimal, not double for numbers with a fractional part.
purge_master_logs_before_date() fixed
many bugs in corner cases fixed

mysys/my_getsystime.c:
  compilation failure fixed
sql/sql_parse.cc:
  don't cut corners. it backfires.
2011-06-06 20:28:15 +02:00
Igor Babaev
f03a3ee54f Merged the code of mwl 106 into the latest 5.3 with mwl 90 pushed.
Resolved all conflicts and failures.
2011-06-04 19:56:06 -07: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
dda9577d55 comments 2011-05-21 18:41:56 +02:00
Sergei Golubchik
7c459960ec db_low_byte_first is gone 2011-05-20 23:56:13 +02:00
Igor Babaev
89cf840cd9 Merge 2011-05-20 12:47:39 -07:00
Sergei Golubchik
f06cac336b post review changes 2
sql/event_parse_data.cc:
  don't use "not_used" variable
sql/item_timefunc.cc:
  Item_temporal_func::fix_length_and_dec()
  and other changes
sql/item_timefunc.h:
  introducing Item_timefunc::fix_length_and_dec()
sql/share/errmsg.txt:
  don't say "column X" in the error message that used not only for columns
2011-05-19 19:16:17 +02:00
Sergei Golubchik
8ddcd0cda8 post-review changes 1
include/my_time.h:
  remove duplicate defines.
  cast to ulonglong to avoid overflow
sql/field.cc:
  perform sign extension when reading packed TIME values
sql/item_cmpfunc.cc:
  when converting a string to a date for the purpose of comparing it with another date,
  we should ignore strict sql mode.
sql/item_timefunc.cc:
  better error message
sql/item_timefunc.h:
  limit decimals appropriately
sql/share/errmsg.txt:
  don't refer to an object as a "column" in error messages that are used not only for columns.
2011-05-19 19:01:46 +02:00
Igor Babaev
704f97035f Merged the code of MWL#106 into 5.3
Resolved all conflicts, bad merges and fixed a few minor bugs in the code.
Commented out the queries from multi_update, view, subselect_sj, func_str,
derived_view, view_grant that failed either with crashes in ps-protocol or
with wrong results.
The failures are clear indications of some bugs in the code and these bugs
are to be fixed.
2011-05-16 22:39:43 -07: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
Michael Widenius
f458e198c0 Merge with 5.2 2011-05-16 14:05:45 +03:00
Michael Widenius
f09f1c7c7d Merge with dynamic column code 2011-05-12 14:30:34 +03:00
Sergei Golubchik
e343a2c134 small enhancement of the create table options feature:
no unnecessary casting from void*, more type safety.
typos fixed.
2011-05-10 18:19:11 +02: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