Commit graph

105 commits

Author SHA1 Message Date
msvensson@pilot.blaudden
a65d12a830 Backport of TIME->MYSQL_TIME / Y2K fixset
Made year 2000 handling more uniform
Removed year 2000 handling out from calc_days()
The above removes some bugs in date/datetimes with year between 0 and 200
Now we get a note when we insert a datetime value into a date column
For default values to CREATE, don't give errors for warning level NOTE
Fixed some compiler failures
Added library ws2_32 for windows compilation (needed if we want to compile with IOCP support)
Removed duplicate typedef TIME and replaced it with MYSQL_TIME

Better (more complete) fix for: Bug#21103 "DATE column not compared as DATE"
Fixed properly Bug#18997 "DATE_ADD and DATE_SUB perform year2K autoconversion magic on 4-digit year value"
Fixed Bug#23093 "Implicit conversion of 9912101 to date does not match cast(9912101 as date)"
2007-05-16 10:44:59 +02:00
holyfoot/hf@mysql.com/hfmain.(none)
a016f71c45 bug #16546 (DATETIME+0 not always coerced the same way)
fix for cast( AS DATETIME)+0 in 5.0 and above versions.
  val_real now works using val_decimal for DATETIME Items
  Superfluous val_real() methods deleted
2007-03-22 12:44:38 +04:00
holyfoot/hf@mysql.com/hfmain.(none)
da5769fe6a Merge mysql.com:/home/hf/work/mrg/mysql-4.1-opt
into  mysql.com:/home/hf/work/mrg/mysql-5.0-opt
2007-03-22 12:26:32 +04:00
holyfoot/hf@mysql.com/hfmain.(none)
e0f0507f99 bug #16546 (DATETIME + 0 not always coerced in the same way)
fix for cast( AS DATETIME) + 0 operation.
  I just implemented Item_datetime_typecast::val() method
  as it is usually done in other classes.
  Should be fixed more radically in 5.0
2007-03-22 12:24:56 +04:00
kent@mysql.com/kent-amd64.(none)
6523aca729 my_strtoll10-x86.s:
Corrected spelling in copyright text
Makefile.am:
  Don't update the files from BitKeeper
Many files:
  Removed "MySQL Finland AB & TCX DataKonsult AB" from copyright header
  Adjusted year(s) in copyright header 
Many files:
  Added GPL copyright text
Removed files:
  Docs/Support/colspec-fix.pl
  Docs/Support/docbook-fixup.pl
  Docs/Support/docbook-prefix.pl
  Docs/Support/docbook-split
  Docs/Support/make-docbook
  Docs/Support/make-makefile
  Docs/Support/test-make-manual
  Docs/Support/test-make-manual-de
  Docs/Support/xwf
2006-12-31 01:02:27 +01:00
kent@mysql.com/kent-amd64.(none)
226a5c833f Many files:
Changed header to GPL version 2 only
2006-12-23 20:17:15 +01:00
holyfoot/hf@mysql.com/deer.(none)
e95e23b0f3 Merge bk@192.168.21.1:mysql-5.0-opt
into  mysql.com:/home/hf/work/mysql-5.0-0mrg
2006-11-17 10:30:16 +04:00
holyfoot/hf@mysql.com/deer.(none)
4fb00857ca bug #19491 (CAST do DATETIME wrong result) 2006-10-25 20:14:39 +05:00
Kristofer.Pettersson@naruto.
887f3b9d42 Bug#21811 Odd casting with date + INTERVAL arithmetic
- Type casting was not consequent, thus when adding a DATE type with
  a WEEK interval the result type was DATETIME and not DATE as is the
  norm.
- By changing the order of the date internal enumerations the deviant
  type casting is resolved (Item_date_add_interval::fix_length_and_dec()
  which determines result type for this operation assumes that addition
  of any interval with value <= INTERVAL_DAY to date value will result
  in date). There are two independant places to change:
  interval_names[] and interval_type.
2006-10-02 12:37:01 +02:00
evgen@moonbone.local
7f24667598 Manually merged 2006-06-17 02:11:12 +04:00
evgen@moonbone.local
28cf3c3e64 Manually merged 2006-06-17 00:58:36 +04:00
evgen@moonbone.local
e35a0ca4b7 Manually merged 2006-06-14 23:54:08 +04:00
evgen@moonbone.local
67de8c46a5 Fixed bug#16377: result of DATE/TIME functions were compared as strings which
can lead to a wrong result.

All date/time functions has the STRING result type thus their results are
compared as strings. The string date representation allows a user to skip 
some of leading zeros. This can lead to wrong comparison result if a date/time 
function result is compared to such a string constant.

The idea behind this bug fix is to compare results of date/time functions
and data/time constants as ints, because that date/time representation is 
more exact. To achieve this the agg_cmp_type() is changed to take in the
account that a date/time field or an date/time item should be compared 
as ints.

This bug fix is partially back ported from 5.0.

The agg_cmp_type() function now accepts THD as one of parameters. 
In addition, it now checks if a date/time field/function is present in the
list. If so, it tries to coerce all constants to INT to make date/time
comparison return correct result. The field for the constant coercion is
taken from the Item_field or constructed from the Item_func. In latter case
the constructed field will be freed after conversion of all constant items.
Otherwise the result is same as before - aggregated with help of the
item_cmp_type() function.

From the Item_func_between::fix_length_and_dec() function removed the part
which was converting date/time constants to int if possible. Now this is 
done by the agg_cmp_type() function.

The new function result_as_longlong() is added to the Item class. 
It indicates that the item is a date/time item and result of it can be
compared as int. Such items are date/time fields/functions.

Correct val_int() methods are implemented for classes Item_date_typecast, 
Item_func_makedate, Item_time_typecast, Item_datetime_typecast. All these
classes are derived from Item_str_func and Item_str_func::val_int() converts
its string value to int without regard to the date/time type of these items.

Arg_comparator::set_compare_func() and Arg_comparator::set_cmp_func()
functions are changed to substitute result type of an item with the INT_RESULT
if the item is a date/time item and another item is a constant. This is done
to get a correct result of comparisons like date_time_function() = string_constant.
2006-06-13 19:09:24 +04:00
igor@rurik.mysql.com
940fe6fea6 Merge rurik.mysql.com:/home/igor/tmp_merge
into  rurik.mysql.com:/home/igor/dev/mysql-5.0-0
2006-06-09 17:56:08 -07:00
ramil@mysql.com
2d52881789 Fix for bug #16546: DATETIME+0 not always coerced the same way 2006-05-02 18:00:44 +05:00
bar@mysql.com
3fef2ba6aa Merge mysql.com:/usr/home/bar/mysql-4.1.b18691
into  mysql.com:/usr/home/bar/mysql-5.0
2006-04-17 15:01:55 +05:00
bar@mysql.com
45293fc346 Bug#18691: Converting number to UNICODE string returns invalid result.
Conversion from int and real numbers to UCS2 didn't work fine: 
CONVERT(100, CHAR(50) UNICODE)
CONVERT(103.9, CHAR(50) UNICODE)

The problem appeared because numbers have binary charset, so,
simple charset recast binary->ucs2 was performed
instead of real conversion.

Fixed to make numbers pretend to be non-binary.
2006-04-13 10:55:48 +05:00
ramil@mysql.com
1e29244200 Fix for bug #14360: Date Between Interval Broken. 2006-04-11 16:13:57 +05:00
guilhem@mysql.com
1379dd180f Merge mysql.com:/home/mysql_src/mysql-4.1-gca
into  mysql.com:/home/mysql_src/mysql-5.0-release
2005-11-10 15:13:12 +01:00
guilhem@mysql.com
2df7d97281 Declaring some class members public for BUG#12377:
"Item_date_add_interval needs to have the int_type member as Public".
As explained in the bug report, this change is is to help http://search.cpan.org/~philips/DBIx-MyParse-0.20/
So please keep those members public.
2005-11-10 15:12:22 +01:00
monty@mysql.com
e5f48e13bf Reverting patch for BUG #14009 (use of abs() on null value causes problems with filesort
Fix for bug #14536: SELECT @a,@a:=... fails with prepared statements
2005-11-01 15:54:30 +02:00
monty@mysql.com
19502e8eb5 Review of new pushed code
Removed wrong fix for bug #14009 (use of abs() on null value causes problems with filesort)
Mark that add_time(), time_diff() and str_to_date() can return null values
2005-11-01 13:00:02 +02:00
jani@ua141d10.elisa.omakaista.fi
af50eff0d2 Merge 4.1 - 5.0 2005-10-28 02:36:19 +03:00
aivanov@mysql.com
53e90b53bc Fixed BUG#12963, BUG#13000: wrong VIEW creation with DAYNAME(),
DAYOFWEEK(), and WEEKDAY().
2005-09-14 20:25:00 +04:00
jimw@mysql.com
9e4a9e23c6 Make SYSDATE() behave as in Oracle: always the current datetime, not the
datetime of when the current statement began. This also makes SYSDATE()
not safe in replication. (Bug #12562)
2005-08-24 15:50:58 -07:00
evgen@moonbone.local
0f9b982970 Fix bug #12298 Typo in timestampdiff() function name results in erroneous
view being created.

Item_func_timestamp_diff::func_name() were returning function name as
"timestamp_diff" thus when view was executed function parameters wasn't 
properly recognized and error was raised.
2005-08-12 22:42:50 +04:00
sergefp@mysql.com
0dba629a5e Manual merge 2005-08-07 21:30:46 +00:00
evgen@moonbone.local
697836c77f Fix bug#12266 GROUP BY DATE(LEFT(column,8)) returns result strings with reduced
length.

When temporary field created for DATE(LEFT(column,8)) expression, max_length
value is taken from Item_date_typecast, and it is getting it from underlaid
Item_func_left and it's max_length is 8 in given expression. And all this
results in stripping last 2 digits.

To Item_date_typecast class added its own fix_length_and_dec() function 
that sets max_length value to 10, which is proper for DATE field.
2005-08-04 18:05:33 +04:00
bell@sanja.is.com.ua
d3905f3d0e Name resolution context added (BUG#6443) 2005-07-01 07:05:42 +03:00
bell@sanja.is.com.ua
02cac1c5e6 fixed time_format printing (BUG#7521) 2005-06-20 14:56:17 +03:00
bell@sanja.is.com.ua
a11677026f fixed printing of sum(distinct ) & avg(distinct ) & cast(... as decimal) (BUG#7015, BUG#11387) 2005-06-17 17:27:47 +03:00
msvensson@neptunus.(none)
34cec09efb Merge neptunus.(none):/home/msvensson/mysql/bug10241
into neptunus.(none):/home/msvensson/mysql/mysql-5.0
2005-05-09 11:26:48 +02:00
msvensson@neptunus.(none)
5b5565c30a BUG#10241 cygwin port: invalid pragma interface directives
- Introduce ifdefs so we can control when to use #pragma interface on cygwin
2005-05-04 15:05:56 +02:00
hf@deer.(none)
b94a482ee9 Precision Math implementation 2005-02-09 02:50:45 +04:00
dlenev@mysql.com
2276bfa374 Manual merge of fixes for bugs #7899 "CREATE TABLE .. SELECT .. and
CONVERT_TZ() function does not work well together" and bug #7705 
"CONVERT_TZ() crashes with subquery/WHERE on index column" in 5.0
tree.
2005-01-28 10:22:50 +03:00
dlenev@brandersnatch.localdomain
80282016c2 Fix for bug #7899 "CREATE TABLE .. SELECT .. and CONVERT_TZ() function
does not work well together". Now using simplier and more correct
implementation of st_lex::unlink_first_table()/link_first_table_back() 
(It also nicely handles case when global table list is created because
of implictly used time zone tables). (2nd attempt)

Fix for bug #7705 "CONVERT_TZ() crashes with subquery/WHERE on index
column". Implemented new approach for caching objects for constant
time zone arguments. Now instead of determining whenever these arguments
are constants and performing time zone lookup at fix_fields() stage, we
do it on first get_date() invocation.

Cleanup of global @@time_zone variable handling.
2005-01-26 22:25:02 +03:00
konstantin@mysql.com
e5f4c7a0bd Rename: Item::val -> Item::val_real(). 2004-11-11 21:39:35 +03:00
monty@mysql.com
afbe601302 merge with 4.1 2004-10-29 19:26:52 +03:00
bar@mysql.com
2c86049dec Bug #5228 ORDER BY CAST(enumcol) sorts incorrectly under certain conditions 2004-09-07 15:42:19 +05:00
monty@mysql.com
31122efde7 Merge with 4.1
(Includes merge of arena code in 4.1 and 5.0)
2004-09-06 15:14:10 +03:00
dlenev@brandersnatch.localdomain
f49d4f5350 Fix for bug #4508 "CONVERT_TZ() function with new time zone as param crashes server".
Instead of trying to open time zone tables during calculation of CONVERT_TZ() function
or setting of @@time_zone variable we should open and lock them with the rest of 
statement's table (so we should add them to global table list) and after that use such 
pre-opened tables for loading info about time zones.
2004-08-10 12:42:31 +04:00
monty@mysql.com
1e31199995 Merge with 4.1.3-beta 2004-07-07 11:29:39 +03:00
dlenev@brandersnatch.localdomain
09ba29e539 WL#1264 "Per-thread time zone support infrastructure".
Added basic per-thread time zone functionality (based on public
domain elsie-code). Now user can select current time zone
(from the list of time zones described in system tables).
All NOW-like functions honor this time zone, values of TIMESTAMP
type are interpreted as values in this time zone, so now
our TIMESTAMP type behaves similar to Oracle's TIMESTAMP WITH
LOCAL TIME ZONE (or proper PostgresSQL type).
  
WL#1266 "CONVERT_TZ() - basic time with time zone conversion 
function".
  
Fixed problems described in Bug #2336 (Different number of warnings 
when inserting bad datetime as string or as number). This required
reworking of datetime realted warning hadling (they now generated 
at Field object level not in conversion functions).
  
Optimization: Now Field class descendants use table->in_use member
instead of current_thd macro.
2004-06-18 10:11:31 +04:00
pem@mysql.com
dfd59e296e Merge 4.1 -> 5.0. 2004-04-07 19:07:44 +02:00
dlenev@jabberwock.localdomain
f6bff2e6c6 WL#1266 "Separate auto-set logic from TIMESTAMP type."
Final version of patch.

Adds support for specifying of DEFAULT NOW() and/or ON UPDATE NOW()
clauses for TIMESTAMP field definition.
Current implementation allows only one such field per table and
uses several unireg types for storing info about this properties of
field. It should be replaced with better implementation when new
.frm format is introduced.
2004-04-02 10:12:53 +04:00
bell@sanja.is.com.ua
2b45b53066 DBUG_ASSERT(fixed == 1); added to val*
small optimisation in signed_literal
2004-03-18 15:14:36 +02:00
gluh@gluh.mysql.r18.ru
df0ede69fc Task #835: additional changes fot str_to_date 2004-03-15 18:28:21 +04:00
jani@ua72d24.elisa.omakaista.fi
8dcb41d8d9 Fixed Bug#3115. CAST AS DATE with malformed string returns NULL but IS NULL
is false.
2004-03-09 22:03:01 +02:00
gluh@gluh.mysql.r18.ru
d9a412dcc3 post-merge fixes 2003-12-08 15:18:29 +04:00
gluh@gluh.mysql.r18.ru
ec8749249a WL#530&531: TIMESTAMPADD, TIMESTAMPDIFF functions
Syntax for TIMESTAMPADD:

TIMESTAMPADD(interval, integer_expression, datetime_expression)

interval:= FRAC_SECOND | SECOND | MINUTE | HOUR | DAY | WEEK | MONTH | 
QUARTER | YEAR

Supported SQL_TSI_  prefix  (like SQL_TSI_SECOND)

Syntax for TIMESTAMPDIFF:

TIMESTAMPDIFF(interval, datetime_expression1, datetime_expression2)

interval:= FRAC_SECOND | SECOND | MINUTE | HOUR | DAY | WEEK | MONTH | 
QUARTER | YEAR

Supported SQL_TSI_  prefix  (like SQL_TSI_SECOND)
2003-12-08 14:41:41 +04:00