[MDEV-31552] Cursor protocol gives wrong result with aggregate function and optimizer hints "straight_join" when there is no resultset Created: 2023-06-27  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.4, 10.5, 10.6, 10.9, 10.10, 11.0, 11.1, 11.2
Fix Version/s: 10.4, 10.5, 10.6, 11.0, 11.1, 11.2

Type: Bug Priority: Major
Reporter: Lena Startseva Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-31005 Make working cursor-protocol Stalled

 Description   

Testcase:

create table t1
(
	PARENT_ID int(10) unsigned NOT NULL AUTO_INCREMENT,
	PARENT_FIELD VARCHAR(10),
	PRIMARY KEY (PARENT_ID)
);
 
create table t2
(
	CHILD_ID INT NOT NULL AUTO_INCREMENT,
	PARENT_ID INT NOT NULL,
	CHILD_FIELD varchar(10),
	PRIMARY KEY (CHILD_ID)
);
 
INSERT INTO t1 (PARENT_FIELD)
SELECT 'AAAA';
 
INSERT INTO t2 (PARENT_ID, CHILD_FIELD)
SELECT 1, 'BBBB';
 
select
 t1.PARENT_ID,
 min(CHILD_FIELD)
 from t1 straight_join t2
 where t1.PARENT_ID = 1
 and t1.PARENT_ID = t2.PARENT_ID
 and t2.CHILD_FIELD = "ZZZZ";
 
DROP TABLES t1, t2;

Expected result:

PARENT_ID	min(CHILD_FIELD)
NULL	NULL

Actual result:

PARENT_ID	min(CHILD_FIELD)
0	NULL


Generated at Thu Feb 08 10:24:44 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.