The section at the end, which is executed first, contains the necessary database locking and schema checking opcodes. These cannot be generated before the rest of the program has analysed which operations are performed on which tables and therefore which of the attached database(s) needs to be locked and at which level. It is much easier to goto back and forth (change just the target of the goto at opcode 1) than to relocate all the instruction addresses in the code.
The Halt opcode will perform any necessary commit processing and wrap up execution of the bytecode program (like setting SQLITE_DONE if no more rows are available form a SELECT program). I guess it is much easier to have a specfic opcode for this rather than to just "fall off" the end of the program (which would require checking the number of bytecodes generated at every opcode). -----Ursprüngliche Nachricht----- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Dominique Devienne Gesendet: Mittwoch, 29. März 2017 09:41 An: General Discussion of SQLite Database <sqlite-users@mailinglists.sqlite.org> Betreff: [sqlite] Goto's in .explain output Gunter posted this explain VDBE code: asql> explain update mytable set myfield=2 where myconst=7; addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Trace 0 0 0 00 NULL 1 Goto 0 73 0 00 NULL ... 72 Halt 0 0 0 00 NULL 73 VBegin 0 0 0 vtab:1F77F958:2B834C233990 00 NULL 74 Goto 0 2 0 00 NULL And the back and forth between the start and end looks intriguing. Why not just? asql> explain update mytable set myfield=2 where myconst=7; addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Trace 0 0 0 00 NULL 1 VBegin 0 0 0 vtab:1F77F958:2B834C233990 00 NULL ... 72 Halt 0 0 0 00 NULL Is the Halt even required then? Just curious. --DD _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users ___________________________________________ Gunter Hick Software Engineer Scientific Games International GmbH FN 157284 a, HG Wien Klitschgasse 2-4, A-1130 Vienna, Austria Tel: +43 1 80100 0 E-Mail: h...@scigames.at This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users