Hello. First of all, sorry for posting three completely different questions 
into the same message ;)

Question #1. I was working with transactions in InnoDB (MySQL) and noticed a 
weird behavior. Consider we have a table:

CREATE TABLE test (id INT NOT NULL PRIMARY KEY);

and two transactions (from two different connections) are trying to insert a 
record at once:

00:01 Transaction A: BEGIN
00:02 Transaction B: BEGIN
00:03 Transaction A: INSERT INTO test VALUES (1) // works okay
00:04 Transaction B: INSERT INTO test VALUES (1) // aborts with 'duplicate key' 
error! why???
00:05 Transaction A: ROLLBACK // works okay, table remains empty
00:06 Transaction B: ??? // has nothing to do because was unable to insert a 
record into an empty table!

To put it simple, transaction A tried to insert a record but soon aborted 
itself via ROLLBACK. If I understand transactions principle correctly, a 
rolled-back transaction should act like it never happened in the first place, 
and other threads should not see its traces. But for some reason another 
transaction noticed that and refused to insert values into table. The question 
is: is that a correct behavior, and I should keep this in mind, or SQLite would 
handle this scenario different way? :/

-----

Question #2. (well, not really a question :)) Earlier in this list, I noticed 
several replies generally saying "using SELECT * FROM is a no-no, it's evil, 
you should never using that" etc.

If you use fetching methods that give you associated (named) data, like 
mysqli_fetch_assoc() or sqlite_fetch_array(SQLITE_ASSOC), using SELECT * FROM 
is perfectly fine. It gives you simplified queries and allows you to separate 
business logic (i.e. code) from presentation layer (i.e. templates), because 
your logic don't have to worry about what columns are required for templates, 
and what not. Even if your DB schema is modified (row order changes, new rows 
added), your code still works because you use something like $row["id"] or 
$row->id, not $row[5] (which I reckon somewhat unclear).

-----

Question #3. Is anyone still interested in SQLite Documentation in Windows HTML 
Help format I kept posting here in the past? I can continue posting links to 
newer .CHM versions here if you like :)

Regards,
Serge


_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to