mirror of
https://github.com/MariaDB/server.git
synced 2025-01-29 10:14:19 +01:00
fix for wrong QUARTER calculation in EXTRACT() (Bug #18100)
mysql-test/r/func_time.result: expected test results for bug #18100 added mysql-test/t/func_time.test: test case for bug #18100 added sql/item_timefunc.cc: wrong formula for EXTRACT QUARTER, now uses the same calculus as the QUARTER() function
This commit is contained in:
parent
2f2607faef
commit
f7b039cc50
3 changed files with 55 additions and 1 deletions
|
@ -360,6 +360,42 @@ extract(SECOND FROM "1999-01-02 10:11:12")
|
|||
select extract(MONTH FROM "2001-02-00");
|
||||
extract(MONTH FROM "2001-02-00")
|
||||
2
|
||||
SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter;
|
||||
quarter
|
||||
1
|
||||
SELECT EXTRACT(QUARTER FROM '2004-02-15') AS quarter;
|
||||
quarter
|
||||
1
|
||||
SELECT EXTRACT(QUARTER FROM '2004-03-15') AS quarter;
|
||||
quarter
|
||||
1
|
||||
SELECT EXTRACT(QUARTER FROM '2004-04-15') AS quarter;
|
||||
quarter
|
||||
2
|
||||
SELECT EXTRACT(QUARTER FROM '2004-05-15') AS quarter;
|
||||
quarter
|
||||
2
|
||||
SELECT EXTRACT(QUARTER FROM '2004-06-15') AS quarter;
|
||||
quarter
|
||||
2
|
||||
SELECT EXTRACT(QUARTER FROM '2004-07-15') AS quarter;
|
||||
quarter
|
||||
3
|
||||
SELECT EXTRACT(QUARTER FROM '2004-08-15') AS quarter;
|
||||
quarter
|
||||
3
|
||||
SELECT EXTRACT(QUARTER FROM '2004-09-15') AS quarter;
|
||||
quarter
|
||||
3
|
||||
SELECT EXTRACT(QUARTER FROM '2004-10-15') AS quarter;
|
||||
quarter
|
||||
4
|
||||
SELECT EXTRACT(QUARTER FROM '2004-11-15') AS quarter;
|
||||
quarter
|
||||
4
|
||||
SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
|
||||
quarter
|
||||
4
|
||||
SELECT "1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND;
|
||||
"1900-01-01 00:00:00" + INTERVAL 2147483648 SECOND
|
||||
1968-01-20 03:14:08
|
||||
|
|
|
@ -139,6 +139,24 @@ select extract(MINUTE_SECOND FROM "10:11:12");
|
|||
select extract(SECOND FROM "1999-01-02 10:11:12");
|
||||
select extract(MONTH FROM "2001-02-00");
|
||||
|
||||
#
|
||||
# test EXTRACT QUARTER (Bug #18100)
|
||||
#
|
||||
|
||||
SELECT EXTRACT(QUARTER FROM '2004-01-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-02-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-03-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-04-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-05-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-06-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-07-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-08-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-09-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-10-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-11-15') AS quarter;
|
||||
SELECT EXTRACT(QUARTER FROM '2004-12-15') AS quarter;
|
||||
|
||||
|
||||
#
|
||||
# Test big intervals (Bug #3498)
|
||||
#
|
||||
|
|
|
@ -2213,7 +2213,7 @@ longlong Item_extract::val_int()
|
|||
switch (int_type) {
|
||||
case INTERVAL_YEAR: return ltime.year;
|
||||
case INTERVAL_YEAR_MONTH: return ltime.year*100L+ltime.month;
|
||||
case INTERVAL_QUARTER: return ltime.month/3 + 1;
|
||||
case INTERVAL_QUARTER: return (ltime.month+2)/3;
|
||||
case INTERVAL_MONTH: return ltime.month;
|
||||
case INTERVAL_WEEK:
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue