What Next opcode does is advance cursor P1 so that it points to the next
key/data pair in its table or index. If there are no more key/value pairs
then fall through to the following instruction.

But i have a program where i need clarification regarding its operation
(I inserted printf statement in Next opcode which will print next followed
by program counter value - printf("in next %d\n",pc);)


//create table
sql="create table em(name int primary key,age int);"\
    "create table idv(id int primary key,name text);"\
    "create table l(name int primary key,fame int);";

sql="insert into em values(44,21);"\
    "insert into em values(11,20);"\
    "insert into em values(5,21);"\
    "insert into idv values(11,44);"\
    "insert into idv values(44,11);"\
    "insert into idv values(5,180);"\
    "insert into l values(11,11);"\
    "insert into l values(12,20);"\
    "insert into l values(1,20);";

sql="select * from l,em,idv where l.fame=em.age";

vdbe:

   0 Init             0   33    0               00
   1 OpenRead         0   11    0 2             00
   2 OpenRead         2    5    0 2             00
   3 OpenRead         1    2    0 2             00
   4 Rewind           0   30    0               00
   5 Rewind           2   29    0               00
   6 Once             0   15    0               00
   7 OpenAutoindex    3    3    0 k(3,nil,nil,nil) 00
   8 Rewind           1   15    0               00
   9 Column           1    1    2               00
  10 Column           1    0    3               00
  11 Rowid            1    4    0               00
  12 MakeRecord       2    3    1               00
  13 IdxInsert        3    1    0               10
  14 Next             1    9    0               03
  15 Column           0    1    5               00
  16 IsNull           5   28    0               00
  17 Affinity         5    1    0 D             00
  18 SeekGE           3   28    5 1             00
  19 IdxGT            3   28    5 1             00
  20 Column           0    0    6               00
  21 Column           0    1    7               00
  22 Column           3    1    8               00
  23 Column           3    0    9               00
  24 Column           2    0   10               00
  25 Column           2    1   11               00
  26 ResultRow        6    6    0               00
  27 Next             3   19    0               00
  28 Next             2    6    0               01
  29 Next             0    5    0               01
  30 Close            0    0    0               00
  31 Close            2    0    0               00
  32 Halt             0    0    0               00
  33 Transaction      0    0 45819 0             01
  34 TableLock        0   11    0 l             00
  35 TableLock        0    5    0 idv           00
  36 TableLock        0    2    0 em            00
  37 Goto             0    1    0               00

result:

in next 14
in next 14
in next 14
in next 28
in next 28
in next 28
in next 29
12,20,11,20,11,44.
in next 27
in next 28
12,20,11,20,44,11.
in next 27
in next 28
12,20,11,20,5,180.
in next 27
in next 28
in next 29
1,20,11,20,11,44.
in next 27
in next 28
1,20,11,20,44,11.
in next 27
in next 28
1,20,11,20,5,180.
in next 27
in next 28
in next 29

Here i dont know the behaviour of Next opcode at 27 because whenever it
comes to that opcode it goes to Next opcode at 28.

Reply via email to