On 3/12/20, Doug <dougf....@comcast.net> wrote: > > Something triggered me when I looked at the generated code: you use the > contents of register 2 for the constant value each time through the loop. > What if the select looks like this, with more than one function call in the > coalesce? Do you handle it properly? > > SELECT coalesce(a, abs(0), abs(1), abs(2)) FROM t1;
addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Init 0 23 0 00 Start at 23 1 OpenRead 0 2 0 1 00 root=2 iDb=0; t1 2 Explain 2 0 0 SCAN TABLE t1 00 3 Rewind 0 22 0 00 4 Column 0 0 1 00 r[1]=t1.a 5 NotNull 1 20 0 00 if r[1]!=NULL goto 20 6 Once 0 9 0 00 7 Integer 0 3 0 00 r[3]=0 8 Function 1 3 2 abs(1) 00 r[2]=func(r[3]) 9 SCopy 2 1 0 00 r[1]=r[2] 10 NotNull 1 20 0 00 if r[1]!=NULL goto 20 11 Once 0 14 0 00 12 Integer 1 5 0 00 r[5]=1 13 Function 1 5 4 abs(1) 00 r[4]=func(r[5]) 14 SCopy 4 1 0 00 r[1]=r[4] 15 NotNull 1 20 0 00 if r[1]!=NULL goto 20 16 Once 0 19 0 00 17 Integer 2 7 0 00 r[7]=2 18 Function 1 7 6 abs(1) 00 r[6]=func(r[7]) 19 SCopy 6 1 0 00 r[1]=r[6] 20 ResultRow 1 1 0 00 output=r[1] 21 Next 0 4 0 01 22 Halt 0 0 0 00 23 Transaction 0 0 1 0 01 usesStmtJournal=0 24 Goto 0 1 0 00 -- D. Richard Hipp d...@sqlite.org _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users