mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-30 06:24:21 +01:00
This PR is to support `Update` queries. Follows sqlite behavior as much as possible. ### limbo ```console limbo> create table t (a,b,c); limbo> explain update t set a = 1 where b = 2; addr opcode p1 p2 p3 p4 p5 comment ---- ----------------- ---- ---- ---- ------------- -- ------- 0 Init 0 18 0 0 Start at 18 1 OpenWriteAsync 0 2 0 0 2 OpenWriteAwait 0 0 0 0 3 RewindAsync 0 0 0 0 4 RewindAwait 0 17 0 0 Rewind table t 5 Column 0 1 4 0 r[4]=t.b 6 Ne 4 5 15 0 if r[4]!=r[5] goto 15 7 RowId 0 6 0 0 r[6]=t.rowid 8 IsNull 6 17 0 0 if (r[6]==NULL) goto 17 9 Integer 1 1 0 0 r[1]=1 10 Column 0 1 2 0 r[2]=t.b 11 Column 0 2 3 0 r[3]=t.c 12 MakeRecord 1 3 7 0 r[7]=mkrec(r[1..3]) 13 InsertAsync 0 7 6 0 14 InsertAwait 0 0 0 0 15 NextAsync 0 0 0 0 16 NextAwait 0 5 0 0 17 Halt 0 0 0 0 18 Transaction 0 1 0 0 write=true 19 Integer 2 5 0 0 r[5]=2 20 Goto 0 1 0 0 ``` ### sqlite ```console sqlite> explain update t set a = 1 where b = 2; addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Init 0 15 0 0 Start at 15 1 Null 0 1 2 0 r[1..2]=NULL 2 Noop 1 0 1 0 3 OpenWrite 0 2 0 2 0 root=2 iDb=0; t 4 Rewind 0 14 0 0 5 Column 0 1 5 0 r[5]= cursor 0 column 1 6 Ne 6 13 5 BINARY-8 81 if r[5]!=r[6] goto 13 7 Rowid 0 2 0 0 r[2]= rowid of 0 8 IsNull 2 14 0 0 if r[2]==NULL goto 14 9 Integer 1 3 0 0 r[3]=1 10 Column 0 1 4 0 r[4]= cursor 0 column 1 11 MakeRecord 3 2 1 0 r[1]=mkrec(r[3..4]) 12 Insert 0 1 2 t 7 intkey=r[2] data=r[1] 13 Next 0 5 0 1 14 Halt 0 0 0 0 15 Transaction 0 1 1 0 1 usesStmtJournal=0 16 Integer 2 6 0 0 r[6]=2 17 Goto 0 1 0 0 ``` Closes #1130