The way that parse looks for the index of the field it just added
is broken.  Instead, use LAST_INSERT_ID() to figure it out.

For example, let's say you have 2 'tests' with the subdir set to None/NULL
(which is true for special 'tests' like boot):  the first entry would be
added and then find_test is used to find the first entry with a certain
job index and a subdir.  Then the second boot occurs and the same thing
happens.  The problem is that you then get the test index of the first boot
since they both had the same job index and subdir.  Now, one could correctly
argue that we should have DB constraints to make these things impossible, but
this type of search is always going to be error prone.  The right solution is
to use LAST_INSERT_ID() which grabs the last autonumber ID put into the DB
for that _connection_.  Since parse is single threaded, we know that the
number returned will be correct.


Signed-off-by: Jeremy Orlow <jorlow@google.com>



git-svn-id: http://test.kernel.org/svn/autotest/trunk@1237 592f7852-d20e-0410-864c-8624ca9c26a4
1 file changed