Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let virtual table implementations know which SQL string is being executed #87

Merged
merged 4 commits into from
Dec 21, 2022

Commits on Dec 12, 2022

  1. New sqlite3_module method: xPrepareSql()

    This commit adds a new method named xPrepareSql to sqlite3_module and an
    associated opcode VPrepareSql. That opcode is emitted immediately before
    a VFilter opcode when querying virtual tables.
    
    xPrepareSql takes two arguments: a pointer to the virtual table's cursor
    and, missing from existing sqlite3_module methods, the SQL string being
    executed by the application.
    
    Prior to the introduction of this method, a virtual table that mirrored
    a remote table had no way to tell which columns of the remote server
    were requested by the application. Therefore, such an implementation
    would typically `SELECT *` from the remote table and let callbacks such
    as xColumn() and xNext() decide which data to send back to the
    application. The problem with this approach is that queries that SELECT
    just a subset of the remote columns trigger the transfer of data over
    the network even though they won't be used.
    
    xPrepareSql gives an opportunity for the virtual table implementation to
    inspect the query string and selectively choose which columns from the
    remote server to pull and cache locally.
    
    Because this change introduces a new method to sqlite3_module, new
    modules wishing to implement a callback for xPrepareSql must declare
    a module version (iVersion) 4 or above.
    lucasvr committed Dec 12, 2022
    Configuration menu
    Copy the full SHA
    64b17b8 View commit details
    Browse the repository at this point in the history

Commits on Dec 19, 2022

  1. vdbeExec: remove redundant goto on error path.

    This commit also removes a comment that was left over on the previous
    changeset.
    lucasvr committed Dec 19, 2022
    Configuration menu
    Copy the full SHA
    86826ae View commit details
    Browse the repository at this point in the history
  2. xPrepareSql: require iVersion >= 700

    Following @psarna's advice, use iVersion >= 700 for
    community-contributed methods.
    lucasvr committed Dec 19, 2022
    Configuration menu
    Copy the full SHA
    9e10fd8 View commit details
    Browse the repository at this point in the history
  3. Rename method from PrepareSql to PreparedSql

    This name change is motivated to prevent misunderstandings: the callback
    is not meant to output a prepared SQL statement. Rather, the callback is
    being informed of the SQL statement prepared by SQLite.
    lucasvr committed Dec 19, 2022
    Configuration menu
    Copy the full SHA
    25e2204 View commit details
    Browse the repository at this point in the history