Can you provide an example of the bytecode produced?

In the SQLite shell type:

.explain
explain <query>;

Typical output (with SQLite version 3.7.14.1):

asql> .explain
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

2     OpenEphemeral  1     26    0                    08  NULL

3     VOpen          0     0     0     vtab:1F77F958:2B834C233990  00  NULL

4     Integer        1     1     0                    00  NULL
5     Integer        0     2     0                    00  NULL
6     VFilter        0     40    1                    00  NULL

7     VColumn        0     1     4                    00  
sgb_dd_play_mode_text.game_no
8     Integer        7     5     0                    00  NULL
9     Ne             5     39    4     collseq(BINARY)  6b  NULL
10    Rowid          0     6     0                    00  NULL
... retrieve unchanged fields
17    Integer        2     13    0                    00  NULL
...retrieve unchanged fields
36    MakeRecord     6     26    4                    00  NULL
37    NewRowid       1     5     0                    00  NULL
38    Insert         1     4     5                    08  NULL

39    VNext          0     7     0                    00  NULL

40    Close          0     0     0                    00  NULL
41    Rewind         1     71    0                    00  NULL

...retrieve stored rows

69    VUpdate        0     27    32    vtab:1F77F958:2B834C233990  02  NULL
70    Next           1     42    0                    00  NULL
71    Close          1     0     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


Explanation:

- xBestIndex is called while preparing the statement

- (73) VBegin is called to signal the start of a transaction
- (3) VOpen is called to open the table for reading (typically store a 
read-only file handle in your VT cursor structure)
- (4..6) VFilter is called to establish the rowset fort he cursor (typically 
rewind your data file and retrieve the first record)
- (7..9) WHERE condition is checked
- (10..36) The new records contents is constructed from the VColumn return 
values and the results of the expressions in the SET clause
- (37..38) The new record is stored in an ephemeral table
- (39) VNext is called (typically retrieve the next record)
- (40) VClose is called (typically close the read only file handle in your VT 
cursor structure)
- (42..68) The new record is retreived from the ephemeral table
- (69) VUpdate is called (typically open a read-write file handle and store it 
in your VT table structure)
- (70) retrieve next row for update
- (71) Close the ephemeral table (and automatically drop it)
-(72) End program, calling VCommit to signal the end of the transaction 
(typically flush and close the read-write file handle in the table structure)

Note that opening a read-write file handle is done on the first VUpdate instead 
of VBegin because there may be no rows that require updating.


-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Bob Friesenhahn
Gesendet: Dienstag, 28. März 2017 21:49
An: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Betreff: [sqlite] VT table behavior change between 3.10 and 3.17

We are trying to update from sqlite3 3.10 to 3.17.  Our virtual table modules 
are encountering problems with 3.17 since the 'xOpen' callback is now being 
called for value change and row deletion operations.
Previously it was only being called for read-only queries.

We are using reader/writer locks and there is not a convenient way to 
transition from being a reader to being a writer.  A file is opened by the 
'xOpen' callback and we need to know if the file should be opened read only, or 
read/write.

The change in behavior can only work with virtual table modules which are able 
to smoothly transition between the state established by 'xOpen' to the 
'xUpdate' call or know the intent when 'xOpen' is called.  This did not seem to 
be a requirement before.

In what sqlite3 version did this behavior change?

Is there a way to know when the 'xOpen' callback is called if it is to support 
an update transaction (i.e. 'xUpdate' callback will be called)?

Thanks,

Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/
_______________________________________________
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

Reply via email to