Skip to content

Commit 77eedd1

Browse files
MCOL-5503: Fix broken quarter (mariadb-corporation#2855)
* Fix broken quarter function
1 parent 8f93fc3 commit 77eedd1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mysql-test/columnstore/basic/r/mcs236_extract_function.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ t1_dt EXTRACT(QUARTER FROM t1_dt)
173173
NULL NULL
174174
1561-12-31 12:34:56 4
175175
2017-02-01 12:12:12 1
176-
2020-11-11 12:12:12 3
176+
2020-11-11 12:12:12 4
177177
SELECT t1_dt, EXTRACT(YEAR FROM t1_dt) FROM t1 ORDER BY 1;
178178
t1_dt EXTRACT(YEAR FROM t1_dt)
179179
NULL NULL

utils/funcexp/func_extract.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ long long dateGet(uint64_t time, IntervalColumn::interval_type unit, bool dateTy
7575

7676
case IntervalColumn::INTERVAL_MICROSECOND: return msec;
7777

78-
case IntervalColumn::INTERVAL_QUARTER: return month / 4 + 1;
78+
case IntervalColumn::INTERVAL_QUARTER: return (month - 1) / 3 + 1;
7979

8080
case IntervalColumn::INTERVAL_WEEK: return helpers::calc_mysql_week(year, month, day, 0);
8181

0 commit comments

Comments
 (0)