On 16 November 2011 20:51, Mika Fischer <[email protected]> wrote: > > I would like to implement get_affected_rows for the sqlite3 backend, > which currently always returns -1.
Good news! > There's support for this in the > SQLite3 API, so it should be relatively easy. > > I have however two questions: > > 1) There's sqlite3_changes and sqlite3_total_changes. The difference > is that the former does not include changes caused by triggers and > foreign key actions, while the latter does. Which one should be used, > so that the behavior is consistent with the other backends? > http://www.sqlite.org/c3ref/changes.html > http://www.sqlite.org/c3ref/total_changes.html In my opinion, it is sqlite3_changes() AFAIK, scripting bindings like PHP to SQLite use this one. PostgreSQL backend uses PQcmdTuples. MySQL backend uses mysql_affected_rows. The sqlite3_changes() seems to be close approximation to these two. > 2) Both functions return the changes for the most recently completed > SQL statement for the connection. Since get_affected_rows is a > function of soci::statement, should I always call > sqlite_(total_)changes and save the value in case the user later calls > get_affected_rows, or is it OK if the function gives incorrect values > in case another statement was executed in the meantime? PQcmdTuples and mysql_affected_rows functions are usually called immediately after executing statement and return value related to this most recent statement. So, I think there is no need to save the value returned by sqlite3_changes nor accumulate it. The expected use case can outlined as this (pseudo-code): statement s s.execute s.get_affected_rows s.execute s.get_affected_rows p.s. If you use GitHub, you may prefer to fork SOCI upstream mirror https://github.com/SOCI/soci apply your changes, then send me pull request (my GitHub username: mloskot). Eventually, I push accepted patches to the official Git repo at SF.net. Thanks for help! Best regards, -- Mateusz Loskot, http://mateusz.loskot.net Charter Member of OSGeo, http://osgeo.org Member of ACCU, http://accu.org ------------------------------------------------------------------------------ All the data continuously generated in your IT infrastructure contains a definitive record of customers, application performance, security threats, fraudulent activity, and more. Splunk takes this data and makes sense of it. IT sense. And common sense. http://p.sf.net/sfu/splunk-novd2d _______________________________________________ Soci-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/soci-users
