Author Alex.LordThorsen
Recipients Alex.LordThorsen, jim_minter, r.david.murray
Date 2015-05-10.21:03:50
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1431291831.15.0.636249224449.issue16864@psf.upfronthosting.co.za>
In-reply-to
Content
Updated the patch to have a versionchanged for lastrowid in Doc/Library/sqlite3.rst and Doc/whatsnew/3.5.rst

One thing of note is that I wasn't able to get the indentation to be on the same level for sqlite3.rst (it would either intent the description text or the versionchange text).

Now that I'm actually starting to understand the dbapi and sqlite3 I've come to the conclusion that the lastrowid method should update the lastrowid for the INSERT OR ROLLBACK, INSERT OR ABORT, INSERT OR FAIL, INSERT OR IGNORE statements as well as the INSERT and INSERT OR REPLACE statements. 

I'm unsure how hard or simple supporting those statements will be

The code in question is

 704         Py_DECREF(self->lastrowid);$
 705         if (!multiple && statement_type == STATEMENT_INSERT) {$
 706             sqlite_int64 lastrowid;$
 707             Py_BEGIN_ALLOW_THREADS$
 708             lastrowid = sqlite3_last_insert_rowid(self->connection->db);$
 709             Py_END_ALLOW_THREADS$
 710             self->lastrowid = _pysqlite_long_from_int64(lastrowid);

And the difficulty will be if sqlite3_last_insert_rowid (line 708) does or doesn't return a row id if the OR STATEMENT portion of those inserts are triggered.

The Problem I'm having is that when I tried to find sqlite3_last_insert_rowid in the Modules/_sqlite directory I got nothing

$ grep -r "sqlite3_last_insert_rowid" Modules/_sqlite/
Modules/_sqlite//cursor.c:            lastrowid = sqlite3_last_insert_rowid(self->connection->db);

When I pulled the grep out to the entire cpython repository 

$ grep -r "sqlite3_last_insert_rowid" .
Binary file ./build/lib.macosx-10.10-x86_64-3.5-pydebug/_sqlite3.cpython-35dm-darwin.so matches
Binary file ./build/lib.macosx-10.10-x86_64-3.5-pydebug/_sqlite3.so matches
Binary file ./build/temp.macosx-10.10-x86_64-3.5-pydebug/Users/alexlord/mercurial/cpython/Modules/_sqlite/cursor.o matches
./Modules/_sqlite/cursor.c:            lastrowid = sqlite3_last_insert_rowid(self->connection->db);

I still didn't find anything and I'm not sure where to go from here.
History
Date User Action Args
2015-05-10 21:03:51Alex.LordThorsensetrecipients: + Alex.LordThorsen, r.david.murray, jim_minter
2015-05-10 21:03:51Alex.LordThorsensetmessageid: <1431291831.15.0.636249224449.issue16864@psf.upfronthosting.co.za>
2015-05-10 21:03:51Alex.LordThorsenlinkissue16864 messages
2015-05-10 21:03:51Alex.LordThorsencreate