Coder Social home page Coder Social logo

Comments (9)

IreneKnapp avatar IreneKnapp commented on July 17, 2024

My recollection is that sqlite returns that error when the number of parameter bindings doesn't match the number the prepared statement is expecting. I see that the inputs are deterministic, so... maybe check whether there was an earlier failure when the statement was prepared?

from direct-sqlite.

aryairani avatar aryairani commented on July 17, 2024

Hi @IreneKnapp, thanks for the quick reply and suggestion! Though... I'm not sure how to do that? 😅

Looking at https://github.com/nurpax/sqlite-simple/blob/master/Database/SQLite/Simple.hs#L195 it looks like there is already a runtime check that would throw a different sort of error if the number of parameter bindings doesn't match the number the prepared statement is expecting.

And preparing the statement with sqlite-simple's query looks like it's calling direct-sqlite's prepare, which should throw its own error if something failed when the statement was prepared, if I'm reading it right?

Do you know of any way to make sqlite chattier to maybe explain itself about this? :) Or did I overlook some other important thing? *pokes at sqlite3 C source*

Thanks in advance :)

from direct-sqlite.

aryairani avatar aryairani commented on July 17, 2024

Maybe I need to run with a version of sqlite3 that has SQLITE_DEBUG enabled? Do you happen to know how to do that? direct-sqlite is kind of magic to me, just being a dependency of the sqlite-simple library I was directly using, and I have no common sense around how C libraries (like sqlite) maybe get bundled with Haskell libraries (like direct-sqlite). Ok thanks :)

from direct-sqlite.

aryairani avatar aryairani commented on July 17, 2024

image
Maybe it's this. 🤞

from direct-sqlite.

aryairani avatar aryairani commented on July 17, 2024

Update: It wasn't that. 😞

from direct-sqlite.

aryairani avatar aryairani commented on July 17, 2024

Or maybe I need to enable SQLITE_CONFIG_LOG also? I'm trying to add an interface to sqlite3_config to enable it; but don't hesitate to let me know if I'm headed in the wrong direction.

from direct-sqlite.

aryairani avatar aryairani commented on July 17, 2024

After [unsuccessfully?] adding support to direct-sqlite for providing a custom logging handler:

setLogger :: Maybe (Error -> Utf8 -> IO ()) -> IO Error

I changed tactics and added a printf to sqlite.c where it normally invokes the logging handler, and and found that I'm somehow sometimes using a connection after closing it. So that gives me something to go on, even though I'm not sure how it's happening so unpredictably.

Let me know if you'd want to end up with a PR for setLogger, in which case I'd ask for your help to understand why my implementation doesn't actually log anything. 🙃

If not, feel free to close this, etc.

from direct-sqlite.

IreneKnapp avatar IreneKnapp commented on July 17, 2024

Glad you figured it out!

That PR sounds handy, I encourage you to send it. Note that I'm not the maintainer anymore, I just happened to see your issue and figured I'd try to help. @sigrlami will review the PR.

from direct-sqlite.

aryairani avatar aryairani commented on July 17, 2024

@IreneKnapp I appreciate it!

from direct-sqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.