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

UPDATE during SELECT #48

Closed
rogerbinns opened this issue Dec 29, 2013 · 3 comments
Closed

UPDATE during SELECT #48

rogerbinns opened this issue Dec 29, 2013 · 3 comments

Comments

@rogerbinns
Copy link
Owner

From Nikolaus@rath.org on June 08, 2009 11:20:52

In http://apsw.googlecode.com/svn/publish/cursor.html it says that the
preferred way to do changes to a database is this one:

| You can also get all the rows immediately by filling in a list:
|
| rows=list( cursor.execute("select * from example") )
| for row in rows:
| cursor.execute("insert ...")
|
| This last approach is recommended since you don’t have to worry
| about the database changing while doing the select.

From this I understand that changing the database (even if using a
different cursor) may mess with the result set of the running query.

However, when I tried to test this behaviour (try attached testcase) it
seems that the result set is not affected.

Unfortunately I also could not find any information about the expected
behavior in this situation on the SQLite website.

Do you have any information on which behaviour I can rely on? I would
rather avoid having te fetch the entire result set into a list, both for
performance and style reasons.

Attachment: 05_apsw.py

Original issue: http://code.google.com/p/apsw/issues/detail?id=48

@rogerbinns
Copy link
Owner Author

From rogerbinns on June 08, 2009 11:34:54

The specific example I was thinking of was someone who posted to the SQLite mailing
list who was doing 'select * from example order by rowid' and then for each row
returned was doing an update that actually turned into a replace (thereby allocating
a new rowid) on that row. He essentially got an infinite number of results.

You can see the discussion at http://www.mail-archive.com/sqlite-users@sqlite.org/msg42660.html In summary there are two important things about SQLite. The first is that it does
not get the next row of results until you ask for them, calculating them on the fly.
The second is that changes/transactions on the same connection are not isolated from
each other.

Status: Accepted
Labels: -Type-Defect Type-Other Component-Docs

@rogerbinns
Copy link
Owner Author

From Nikolaus@rath.org on June 08, 2009 12:17:40

I see. Thank you very much for the link, that clarifies things a lot.

@rogerbinns
Copy link
Owner Author

From rogerbinns on June 08, 2009 17:58:41

I have updated the doc slightly and pointed to the example link above to help make
this all clearer in r453 .

Status: Verified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant