Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?
xRowid() is only called if the (hidden field) rowid is explicitly mentioned in the select list, join condition or where clause(s) of a SELECT statement; or if your VTAB supports write operations (see xUpdate documentation http://www.sqlite.org/vtab.html#the_xupdate_method ). -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Bob Friesenhahn Gesendet: Montag, 12. Dezember 2016 20:50 An: SQLite mailing listBetreff: Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist? On Tue, 13 Dec 2016, Dan Kennedy wrote: >> >> Perhaps SQLITE_NOTFOUND is a correct return code, but the >> documentation does not address return codes from virtual table modules. >> >> What is the correct code to return? If a cursor is being navigated, >> then I would prefer that the cursor continue to the next result row. > > If you want the query to continue, the virtual table methods must > return SQLITE_OK. Anything else will cause SQLite to abandon the query > and return the error to the user. Have the xColumn() method return > NULL in this case I guess. Ok, thanks. > Or you could load all the column values into memory when your virtual > table cursor visits each row of the underlying data. Then you wouldn't > have to handle the current row disappearing on you. We are normally doing column caching as you describe. Even without the caching I can lock for column access at the row level. The case where the row might no longer exist is for xRowid(), but this function does not seem to be called for the table I am looking at. 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
Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?
>On 12/13/2016 01:47 AM, Bob Friesenhahn wrote: >> I am reworking code for a virtual table module and need to provide >> proper error codes from the xColumn() and xRowid() callbacks for the >> case where the row id does not exist, or the current row goes away. >> This problem occurs because the current virtual table module >> implementation does not lock for its entire access (a matter for >> subsequent investigation). >> >> The documentation just says to "return an appropriate error code". >> >> Perhaps SQLITE_NOTFOUND is a correct return code, but the >> documentation does not address return codes from virtual table modules. >> >> What is the correct code to return? If a cursor is being navigated, >> then I would prefer that the cursor continue to the next result row. > >If you want the query to continue, the virtual table methods must return >SQLITE_OK. Anything else will cause SQLite to abandon the query and return the >error to the user. Have the xColumn() method return NULL >in this case I guess. > >Or you could load all the column values into memory when your virtual table >cursor visits each row of the underlying data. Then you wouldn't have to >handle the current row disappearing on you. > I second this suggestion. Unless your underlying data store is (possibly shared) memory that may have already been clobbered, keeping a copy of the row "as seen when xFilter()/xNext() was called" avoids this problem. ___ 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
Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?
Current documentation http://www.sqlite.org/rescode.html suggests you return (267) SQLITE_CORRUPT_VTAB in this case. Other candidates would be SQLITE_IOERR or SQLITE_NOTFOUND. You may also call one or more of the sqlite_result_error() functions to set an error string and/or an error code; current documentation http://www.sqlite.org/vtab.html#the_xcolumn_method suggests you set the error text by calling one of the sqlite_result_text() functions and returning the error code. If your intention is to silently skip the row, you should refrain from calling any of the sqlite_result() functions (or explicitly call sqlite_result_null()) to set a NULL column value and return SQLITE_OK. You just have to hope that a row containing one or more (or even all) "fake" NULL values does not wreck your statement. -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Bob Friesenhahn Gesendet: Montag, 12. Dezember 2016 19:48 An: SQLite mailing listBetreff: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist? I am reworking code for a virtual table module and need to provide proper error codes from the xColumn() and xRowid() callbacks for the case where the row id does not exist, or the current row goes away. This problem occurs because the current virtual table module implementation does not lock for its entire access (a matter for subsequent investigation). The documentation just says to "return an appropriate error code". Perhaps SQLITE_NOTFOUND is a correct return code, but the documentation does not address return codes from virtual table modules. What is the correct code to return? If a cursor is being navigated, then I would prefer that the cursor continue to the next result row. 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
Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?
On Tue, 13 Dec 2016, Dan Kennedy wrote: Perhaps SQLITE_NOTFOUND is a correct return code, but the documentation does not address return codes from virtual table modules. What is the correct code to return? If a cursor is being navigated, then I would prefer that the cursor continue to the next result row. If you want the query to continue, the virtual table methods must return SQLITE_OK. Anything else will cause SQLite to abandon the query and return the error to the user. Have the xColumn() method return NULL in this case I guess. Ok, thanks. Or you could load all the column values into memory when your virtual table cursor visits each row of the underlying data. Then you wouldn't have to handle the current row disappearing on you. We are normally doing column caching as you describe. Even without the caching I can lock for column access at the row level. The case where the row might no longer exist is for xRowid(), but this function does not seem to be called for the table I am looking at. 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
Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?
On 12/13/2016 01:47 AM, Bob Friesenhahn wrote: I am reworking code for a virtual table module and need to provide proper error codes from the xColumn() and xRowid() callbacks for the case where the row id does not exist, or the current row goes away. This problem occurs because the current virtual table module implementation does not lock for its entire access (a matter for subsequent investigation). The documentation just says to "return an appropriate error code". Perhaps SQLITE_NOTFOUND is a correct return code, but the documentation does not address return codes from virtual table modules. What is the correct code to return? If a cursor is being navigated, then I would prefer that the cursor continue to the next result row. If you want the query to continue, the virtual table methods must return SQLITE_OK. Anything else will cause SQLite to abandon the query and return the error to the user. Have the xColumn() method return NULL in this case I guess. Or you could load all the column values into memory when your virtual table cursor visits each row of the underlying data. Then you wouldn't have to handle the current row disappearing on you. Dan. ___ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
[sqlite] Error code for VT xColumn()/xRowid() if row does not exist?
I am reworking code for a virtual table module and need to provide proper error codes from the xColumn() and xRowid() callbacks for the case where the row id does not exist, or the current row goes away. This problem occurs because the current virtual table module implementation does not lock for its entire access (a matter for subsequent investigation). The documentation just says to "return an appropriate error code". Perhaps SQLITE_NOTFOUND is a correct return code, but the documentation does not address return codes from virtual table modules. What is the correct code to return? If a cursor is being navigated, then I would prefer that the cursor continue to the next result row. 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