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

Significant performance improvements and code cleanup #20

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Commits on Sep 24, 2017

  1. Fix tests, which now pass under stack LTS-6.35

    Drop "old-locale" dependency and tests of conversions from obsolete
    "old-time" types.
    
    Added stack.yaml, for 6.35.  Newer LTS versions can't build the tests
    due to version caps on template-haskell in dependencies.  Compilation
    without the tests dependencies now works through at least LTS-9.5 and
    even stackage-nightly-2017-09-20.
    hs-viktor committed Sep 24, 2017
    Configuration menu
    Copy the full SHA
    0e78b38 View commit details
    Browse the repository at this point in the history
  2. Initialize ppst to NULL just in case

    We try to finalize it after failed calls, and, though the SQLite3
    documentation promises that it will be initialized to NULL on error, this
    is liable to elicit compiler warnings, and is not "obviously" correct.
    hs-viktor committed Sep 24, 2017
    Configuration menu
    Copy the full SHA
    45a24ef View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    58c0d2a View commit details
    Browse the repository at this point in the history
  4. Fix warnings

    - Missing type signatures
    - Shadowed names
    - Unused names
    - Ignored results
    - Incomplete pattern matches
    - Missing modules in cabal file
    
    * Fixed all warnings reported by GHC 7 in code and tests
    * Fixed all warnings reported by GHC 8 in the code, tests
      don't yet build due to version conflicts in dependencies.
    hs-viktor committed Sep 24, 2017
    Configuration menu
    Copy the full SHA
    ee94b10 View commit details
    Browse the repository at this point in the history
  5. New connectSqlite3Ext function

    This allows prepared statements to stay open, so that one can avoid the
    penalty of recompiling them each time.  Applications that disable auto
    finish MUST finish() *every* statement handle they prepare().
    
    This also supports use of native octet encodings of non-UTF-8 filenames.
    The existing connect functions are re-implemented in terms of
    connectSqlite3Ext.
    
    When auto-finish is off, it makes no sense to track the open statement
    handles that only the user will close.  Therefore, ChildList becomes
    a (Maybe ChildList) and is unused when auto-finish is disabled.
    
    Since we're not finishing queries when the last result row is read,
    we at least promptly "reset" the statement, freeing up some of the
    underlying resources.
    
    Finally, single-use statements that the library prepares for its own
    internal purposes are never auto-finished, and finished explicitly
    instead.  Most of these will become cached statements in the next commit.
    
    The previous implementation of clone() was incorrect, it forgot the
    filename encoding, this is now preserved along with the auto-finish
    flag.
    hs-viktor committed Sep 24, 2017
    Configuration menu
    Copy the full SHA
    dbf4d78 View commit details
    Browse the repository at this point in the history

Commits on Sep 25, 2017

  1. Bypass preparing BEGIN, COMMIT and ROLLBACK

    We don't need a statement handle for these, just call sqlite3_exec()
    via fexecuteRaw().  Also avoid creating a persistent statement handle for
    the gettables query and the one-shot queries processed by run and runRaw.
    hs-viktor committed Sep 25, 2017
    Configuration menu
    Copy the full SHA
    9d30abc View commit details
    Browse the repository at this point in the history
  2. Save column names on prepare rather than on execute.

    We'll use the "live" values with requests for an already prepared
    statement, and only fall-back to the saved values when finished
    after a previous prepare in auto-finish mode.
    hs-viktor committed Sep 25, 2017
    Configuration menu
    Copy the full SHA
    dbb60cd View commit details
    Browse the repository at this point in the history
  3. Added tests for auto-finish off mode.

    With implicit auto-finish of course the finish happens at the right time
    automatically, but with auto-finish off, a bit more care is required to
    not reset the query before all the desired rows are examined.
    
    The explicit "finish" for the statements used to fetch all rows when
    using the lazy fetchAllRows needs to be delayed until the rows have
    been fully processed (by comparing with the expected values).  This
    is not needed in the non-lazy fetchAllRows' case.
    
    Replaced quickQuery with safeQuickQuery' when not explicitly testing
    quickQuery.  The latter is not safe when auto-finish is off.  Applications
    that disable auto-finish must avoid functions like quickQuery and quickQuery'
    internally leak prepared statements.  NB: quickQuery' could be changed to
    explicitly finish its statement handle.
    hs-viktor committed Sep 25, 2017
    Configuration menu
    Copy the full SHA
    55e9f99 View commit details
    Browse the repository at this point in the history