mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 20:36:16 +01:00 
			
		
		
		
	Updated tests: cases with bugs or which cannot be run with the cursor-protocol were excluded with "--disable_cursor_protocol"/"--enable_cursor_protocol" Fix for v.10.5
		
			
				
	
	
		
			49 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
#
 | 
						|
# Tests for the LAST_VALUE function
 | 
						|
#
 | 
						|
 | 
						|
--disable_warnings
 | 
						|
drop table if exists t1;
 | 
						|
drop database if exists mysqltest;
 | 
						|
--enable_warnings
 | 
						|
 | 
						|
# CREATE TABLE `queue` (
 | 
						|
#  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
 | 
						|
#  `priority` int(11) DEFAULT NULL,
 | 
						|
#  `state` int(11) DEFAULT NULL,
 | 
						|
#  `pid` int(10) unsigned DEFAULT NULL,
 | 
						|
#  `dat` varbinary(200) DEFAULT NULL,
 | 
						|
#  PRIMARY KEY (`id`)
 | 
						|
# )
 | 
						|
 | 
						|
CREATE TABLE t1 (a INT, b INT, c INT, d INT);
 | 
						|
INSERT INTO t1 VALUES (1,3,0,NULL),(2,2,0,NULL),(3,4,0,NULL),(4,2,0,NULL);
 | 
						|
SELECT * FROM t1;
 | 
						|
UPDATE t1 SET c=LAST_VALUE(@last_a:=a,@last_b:=b,@last_c:=c,1), d=4211 WHERE c=0 ORDER BY b DESC LIMIT 1;
 | 
						|
SELECT @last_a, @last_b, @last_c;
 | 
						|
SELECT * FROM t1;
 | 
						|
DROP TABLE t1;
 | 
						|
 | 
						|
#
 | 
						|
# Test with different types
 | 
						|
#
 | 
						|
# PS protocol gives slightly different metadata for the length
 | 
						|
--enable_metadata
 | 
						|
--disable_ps_protocol
 | 
						|
SELECT LAST_VALUE(@last_a:=1,@last_b:=1);
 | 
						|
select @last_b;
 | 
						|
--enable_ps_protocol
 | 
						|
#Check after fix MDEV-31540
 | 
						|
--disable_cursor_protocol
 | 
						|
SELECT LAST_VALUE(@last_a:=1,@last_b:=1.0);
 | 
						|
select @last_b;
 | 
						|
SELECT LAST_VALUE(@last_a:=1,@last_b:="hello");
 | 
						|
select @last_b;
 | 
						|
SELECT date(LAST_VALUE(@last_a:=1,@last_b:="2001-02-03"));
 | 
						|
select @last_b;
 | 
						|
SELECT LAST_VALUE(@last_a:=1,@last_b:="2001-02-03",NULL);
 | 
						|
select @last_b;
 | 
						|
--enable_cursor_protocol
 | 
						|
--disable_metadata
 | 
						|
--error ER_PARSE_ERROR
 | 
						|
SELECT LAST_VALUE();
 |