benluteijn / cherokee

Automatically exported from code.google.com/p/cherokee
0 stars 1 forks source link

handler_dbslayer: buggy when errors are present in a transaction. #235

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Send this through dbslayer, knowing that it would be a duplicate entry that
should fail:
-------
begin;
insert into movie values (1800,'dracula negro',1972,8.9,14182);
commit;
-------

What is the expected output?

It should return the same MYSQL reported when transactions are not involved:

{'MYSQL_ERRNO': 1062,
 'MYSQL_ERROR': "Duplicate entry '1800' for key 1",
 'SUCCESS': 0}

What do you see instead?

{'AFFECTED_ROWS': 0, 'INSERT_ID': 0, 'SUCCESS': 1}

Original issue reported on code.google.com by tah...@gmail.com on 20 Nov 2008 at 12:19

GoogleCodeExporter commented 9 years ago
Incidentally, anything sent after that in the same request (being in or out of 
the
transaction) is not processed.

This would yield no results (and is not reflected in the database).

-------
begin;
insert into movie values (1800,'dracula negro',1972,8.9,14182);
insert into movie values (1801,'bacula',1972,8.9,14182);
select * from movie;
commit;
-------

Original comment by tah...@gmail.com on 20 Nov 2008 at 12:23

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Note the "out of the transaction" part.

-------
begin;
insert into movie values (1800,'dracula negro',1972,8.9,14182);
select * from movie;
commit;
insert into movie values (1801,'bacula',1972,8.9,14182);
-------

Besides not returning SUCCESS=0 for the transaction, the behavior is correct.
However, nos processing the external INSERT is not.

Original comment by tah...@gmail.com on 20 Nov 2008 at 12:29

GoogleCodeExporter commented 9 years ago
Turns out it is not transaction related. Nor specific to reading or writing.

Something as simple as this breaks it:
-------------
select * from fake where id=1000;  -- table doesn't exist
select * from movie where id=1000; -- this query should yield something
-------------

Expected result:
----------------
Should return:

{'MYSQL_ERRNO': 1146,
 'MYSQL_ERROR': "Table 'test.mov' doesn't exist",
 'ROLLBACK_ON_ERROR': 1,
 'ROLLBACK_ON_ERROR_SUCCESS': 1,
 'SUCCESS': 0}

{'RESULT': {'HEADER': ['id', 'title', 'year', 'score', 'votes'],
            'ROWS': [[1000,
                      "can't buy me love",
                      1987,
                      7.4000000000000004,
                      366]],
            'TYPES': ['MYSQL_TYPE_LONG',
                      'MYSQL_TYPE_STRING',
                      'MYSQL_TYPE_NEWDECIMAL',
                      'MYSQL_TYPE_FLOAT',
                      'MYSQL_TYPE_LONG']}}

Returned instead:
-----------------
{'MYSQL_ERRNO': 1146,
 'MYSQL_ERROR': "Table 'test.mov' doesn't exist",
 'ROLLBACK_ON_ERROR': 1,
 'ROLLBACK_ON_ERROR_SUCCESS': 1,
 'SUCCESS': 0}

Additional details:
-------------------
If the queries are executed in reverse, only the RESULT dictionary is returned. 
The
ERRORS are not in the response

Original comment by tah...@gmail.com on 20 Nov 2008 at 4:19

GoogleCodeExporter commented 9 years ago
It has been fixed in trunk.
Great report BTW! :-)

Original comment by alobbs on 21 Nov 2008 at 9:08