Name: Anonymous 2010-04-16 12:53
Hey /prog/
Is it legal to modify a table while there's a read cursor open on it? Is it defined behavior?
For example, in some pseudo-code:
result = sql("SELECT * FROM faggot_table WHERE faggot_type=5;");
for each (result) {
if (whatever) sql("DELETE FROM faggot_table WHERE faggot_id=3;");
}
The reason I ask is because I tested with several database engines from the ENTERPRISE to the toy, and it works on some but errors out in others. So I can't use it in the general case.
However I'd like to know if it should work and some databases suck, if it shouldn't but is supported on some, or if it mustn't and it works by chance on some.
(It could work in some because they prefetch results, and maybe if they prefetch everything the cursor is already closed the moment you read the first row)
Is it legal to modify a table while there's a read cursor open on it? Is it defined behavior?
For example, in some pseudo-code:
result = sql("SELECT * FROM faggot_table WHERE faggot_type=5;");
for each (result) {
if (whatever) sql("DELETE FROM faggot_table WHERE faggot_id=3;");
}
The reason I ask is because I tested with several database engines from the ENTERPRISE to the toy, and it works on some but errors out in others. So I can't use it in the general case.
However I'd like to know if it should work and some databases suck, if it shouldn't but is supported on some, or if it mustn't and it works by chance on some.
(It could work in some because they prefetch results, and maybe if they prefetch everything the cursor is already closed the moment you read the first row)