mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-25 19:04:26 +01:00
SQLite emits a DecrJumpZero instruction after ResultRow even when there are aggregation functions: ``` sqlite> EXPLAIN SELECT avg(age) FROM users LIMIT 1; addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Init 0 13 0 0 Start at 13 1 Integer 1 1 0 0 r[1]=1; LIMIT counter 2 Null 0 2 3 0 r[2..3]=NULL 3 OpenRead 0 2 0 10 0 root=2 iDb=0; users 4 Rewind 0 8 0 0 5 Column 0 9 4 0 r[4]= cursor 0 column 9 6 AggStep 0 4 3 avg(1) 1 accum=r[3] step(r[4]) 7 Next 0 5 0 1 8 AggFinal 3 1 0 avg(1) 0 accum=r[3] N=1 9 Copy 3 5 0 0 r[5]=r[3] 10 ResultRow 5 1 0 0 output=r[5] 11 DecrJumpZero 1 12 0 0 if (--r[1])==0 goto 12 12 Halt 0 0 0 0 13 Transaction 0 0 1 0 1 usesStmtJournal=0 14 Goto 0 1 0 0 ``` This does not seem to have any user-visible difference in semantics because we always jump to Halt regardless of the limit. Howwever, to keep generated code consistent with SQLite and avoid special-case paths, let's just emit the instruction.