Skip to content

Commit 2227552

Browse files
committed
fix: MVCC cursor ignored left join null flag
1 parent 6ba7d05 commit 2227552

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

core/vdbe/execute.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,6 +3082,10 @@ pub fn op_row_id(
30823082
.get_mut(*cursor_id)
30833083
.expect("cursor_id should be valid")
30843084
{
3085+
if btree_cursor.get_null_flag() {
3086+
state.registers[*dest] = Register::Value(Value::Null);
3087+
break;
3088+
}
30853089
if let Some(ref rowid) = return_if_io!(btree_cursor.rowid()) {
30863090
state.registers[*dest].set_int(*rowid);
30873091
} else {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Regression test for MVCC LEFT JOIN NullRow bug.
2+
# MvccLazyCursor::rowid() was not checking null_flag, so after NullRow
3+
# it returned the stale rowid of the last seeked row instead of NULL.
4+
5+
@database :memory:
6+
7+
test mvcc-left-join-null-row {
8+
CREATE TABLE t1(x INTEGER PRIMARY KEY);
9+
CREATE TABLE t2(x INTEGER PRIMARY KEY, v TEXT);
10+
INSERT INTO t1 VALUES (1);
11+
INSERT INTO t2 VALUES (1, 'hello');
12+
SELECT t1.x, t2.x FROM t1 LEFT JOIN t2 ON t1.x = t2.x AND t2.v = 'nonexistent';
13+
}
14+
expect {
15+
1|
16+
}

0 commit comments

Comments
 (0)