Hi! On Oct 15, Jason McManus wrote: > Good afternoon, > > I have had reason to use the new (as of 4.1.1) INSERT .. ON DUPLICATE KEY > UPDATE syntax in MySQL. However, I am a bit confused as to the return > value. Issuing the INSERT .. ON DUP KEY UP statement, upon finding a > duplicate key and updating that record, mysql-client returns "2 rows > affected"; upon inserting a unique row, it returns the expected "1 row > affected".
> I have theorized that the 1st row is referring to a row that temporarily > existed during the insert, then was deleted, and the 2nd row is the row that > was updated (or vice versa), but this is fairly dependent upon how this > statement was implemented; normally a key constraint shouldn't actually > succeed and should return an error before modifying the table (i.e. 0 rows > affected). Thus I would like to address the developers and inquire about > this particular behaviour. See http://bugs.mysql.com/bug.php?id=2709. The reasoning is that the current behaviour is more useful, as it gives more information about what the statement did (see the url above for the example). Regards, Sergei -- __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Sergei Golubchik <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, Senior Software Developer /_/ /_/\_, /___/\___\_\___/ Osnabrueck, Germany <___/ www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]