List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:July 3 2002 4:42pm
Subject:Re: verification upon update, help, please
View as plain text  
At 12:07 -0400 7/3/02, Paul Tomsic wrote:
>Does MySQL prevent updates from occurring when the values involved 
>are the same as the database's current state.

I don't know if "prevent" is the word exactly.  It doesn't bother to update
the row unless you actually change a value.  The phenonenon you're observing
is that the row-count value means "rows actually changed from their
current values" rather than "rows select to be updated".

>
>For instance, if I've got a table
>
>create table updater(
>id int not null primary key auto_increment,
>is_active int not null default 1
>};
>
>insert into updater(is_active) values (1);
>insert into updater(is_active) values (1);
>
>update updater set is_active = 1;
>
>Would MySQL essentially disregard this update statement b/c the 
>values contained within the table are already 1?
>Now, I realize that the values wouldn't be altered, but does the dB
>do pre-checking and see which (if any) rows would be affected by the 
>query, and only run the update against rows that would be changed?
>
>There seems to be some reporting that is displayed which indicates 
>that MySQL DOES indeed to "pre-checking"
>
>mysql> select * from updater;
>+----+-----------+
>| id | is_active |
>+----+-----------+
>|  1 |         1 |
>|  2 |         1 |
>+----+-----------+
>2 rows in set (0.00 sec)
>
>mysql> update updater set is_active = 1;
>Query OK, 0 rows affected (0.00 sec)
>Rows matched: 2  Changed: 0  Warnings: 0
>
>mysql>
>
>any thoughts?
>
>thanks,
>Paul

Thread
verification upon update, help, pleasePaul Tomsic3 Jul
  • Re: verification upon update, help, pleasePaul DuBois3 Jul
RE: verification upon update, help, pleaseNilesh Shah3 Jul