You've already forked mariadb-columnstore-engine
							
							
				mirror of
				https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
				synced 2025-11-03 17:13:17 +03:00 
			
		
		
		
	The most important fix here is the fix of possible buffer overrun in DATEFORMAT() function. A "%W" format, repeated enough times, would overflow the 256-bytes buffer for result. Now we use ostringstream to construct result and we are safe. Changes in date/time projection functions made me fix difference between us and server behavior. The new, better behavior is reflected in changes in tests' results. Also, there was incorrect logic in TRUNCATE() and ROUND() functions in computing the decimal "shift."
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
DROP DATABASE IF EXISTS mcs275_db;
 | 
						|
CREATE DATABASE mcs275_db;
 | 
						|
USE mcs275_db;
 | 
						|
CREATE TABLE t1
 | 
						|
(
 | 
						|
t1_DATE DATE,
 | 
						|
t1_TIME TIME,
 | 
						|
t1_DATETIME DATETIME
 | 
						|
)ENGINE=Columnstore;
 | 
						|
INSERT INTO t1 VALUES('2011-08-27', '22:12:02', '1997-12-12 22:12:02');
 | 
						|
INSERT INTO t1 VALUES('2020-02-19', '23:59:59', '2001-1-1 23:59:59.65');
 | 
						|
INSERT INTO t1 VALUES('1991-05-30', '01:37:50.871', '09-12-11 01:08:59');
 | 
						|
SELECT TIMEDIFF('2011-3-3 1:12:22', '2011-3-4 3:12:11') FROM t1 LIMIT 1;
 | 
						|
TIMEDIFF('2011-3-3 1:12:22', '2011-3-4 3:12:11')
 | 
						|
-25:59:49
 | 
						|
SELECT TIMEDIFF('20:28:30', '11:22:33.4455') FROM t1 LIMIT 1;
 | 
						|
TIMEDIFF('20:28:30', '11:22:33.4455')
 | 
						|
09:05:56.5545
 | 
						|
SELECT t1_DATE, TIMEDIFF(t1_DATE, '2008-02-19 22:22:22') FROM t1 ORDER BY 1;
 | 
						|
t1_DATE	TIMEDIFF(t1_DATE, '2008-02-19 22:22:22')
 | 
						|
1991-05-30	NULL
 | 
						|
2011-08-27	NULL
 | 
						|
2020-02-19	NULL
 | 
						|
SELECT t1_DATE, TIMEDIFF(t1_DATE, '22:22:22') FROM t1 ORDER BY 1;
 | 
						|
t1_DATE	TIMEDIFF(t1_DATE, '22:22:22')
 | 
						|
1991-05-30	NULL
 | 
						|
2011-08-27	NULL
 | 
						|
2020-02-19	NULL
 | 
						|
SELECT t1_TIME, TIMEDIFF(t1_TIME, '2008-02-19 22:22:22') FROM t1 ORDER BY 1;
 | 
						|
t1_TIME	TIMEDIFF(t1_TIME, '2008-02-19 22:22:22')
 | 
						|
01:37:50	NULL
 | 
						|
22:12:02	NULL
 | 
						|
23:59:59	NULL
 | 
						|
SELECT t1_TIME, TIMEDIFF(t1_TIME, '23:59:59') FROM t1 ORDER BY 1;
 | 
						|
t1_TIME	TIMEDIFF(t1_TIME, '23:59:59')
 | 
						|
01:37:50	-22:22:09
 | 
						|
22:12:02	-01:47:57
 | 
						|
23:59:59	00:00:00
 | 
						|
SELECT t1_DATETIME, TIMEDIFF(t1_DATETIME, '2001-02-19 22:22:22') FROM t1 ORDER BY 1;
 | 
						|
t1_DATETIME	TIMEDIFF(t1_DATETIME, '2001-02-19 22:22:22')
 | 
						|
1997-12-12 22:12:02	-838:59:59
 | 
						|
2001-01-01 23:59:59	-838:59:59
 | 
						|
2009-12-11 01:08:59	838:59:59
 | 
						|
SELECT t1_DATETIME, TIMEDIFF(t1_DATETIME, '22:22:22') FROM t1 ORDER BY 1;
 | 
						|
t1_DATETIME	TIMEDIFF(t1_DATETIME, '22:22:22')
 | 
						|
1997-12-12 22:12:02	NULL
 | 
						|
2001-01-01 23:59:59	NULL
 | 
						|
2009-12-11 01:08:59	NULL
 | 
						|
DROP DATABASE mcs275_db;
 |