Value returned from RowsAffected

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Ivo
Posts: 6
Joined: Fri 17 Dec 2004 03:38
Location: Brazil

Value returned from RowsAffected

Post by Ivo » Fri 17 Dec 2004 04:12

When I make an updating in a table where doesn't affect any line, using MyQuery, the RowsAffected returned is 1.

Example:

insert into products ( product_id, product_price) values (1, 0)

the value of Product_price in update is same the value in the insert

update products set product_price = 0 where Product_id = 1

RowsAffected returned is 1

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Value returned from RowsAffected

Post by Ikar » Fri 17 Dec 2004 13:39

RowsAffected returns a number of records responding WHERE clause. RowsAffected doesn't consider that actually update can be not performed as new data coincide with old data.

Ivo
Posts: 6
Joined: Fri 17 Dec 2004 03:38
Location: Brazil

Post by Ivo » Fri 17 Dec 2004 17:18

Have MyDAC another property consider that update actually updated data due to the fact that this is sdandard behavior for MySQL and much important for my application
if you execute the update above in MySql command-line tool, for example, the return will always be "0 rows affected"

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Mon 20 Dec 2004 15:46

Not, MyDAC doesn't provide this functionality.

Ivo
Posts: 6
Joined: Fri 17 Dec 2004 03:38
Location: Brazil

Post by Ivo » Tue 21 Dec 2004 21:47

We found in function mysql_rel_connect() in MySQL API Documentation the parameter client_flag that is a combination of flags, for example, CLIENT_COMPRESS and CLIENT_FOUND_ROWS.
CLIENT_FOUND_ROWS when set, return the number of found(matched) rows, not the number of affected rows.
CLIENT_FOUND_ROWS is usually 0, but it is set in MyDAC.
In TMyConnectionOptions exist a property Compress that probably change flag CLIENT_COMPRESS
Would it be possible you add a property in TMyConnectionOptions that change flag CLIENT_FOUND_ROWS ????? :?:

Thanks

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Wed 22 Dec 2004 15:39

As a rule we don't change public interface without persuasive reasons. Please specify to solve what tasks you need this behaviour.

Ivo
Posts: 6
Joined: Fri 17 Dec 2004 03:38
Location: Brazil

Post by Ivo » Thu 23 Dec 2004 20:52

Have cases that I want to know the number of found(matched) rows responding WHERE clause, regardless what it was actually updated.
In these cases the flag CLIENT_FOUND_ROWS must be set. This is standard behavior for MyDac.

Have cases that I want to Know the number of affected rows to make a log of data actually changed.
In these cases the flag CLIENT_FOUND_ROWS must be not set. This is standard behavior for MySQL Server.
I believe that these cases are more important than cases above

Ikar
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Post by Ikar » Fri 24 Dec 2004 11:45

At first MyDAC builds we uses the standard behaviour of MySQL. But by numerous requests of our users we changed it at the current one.

That functionality you specified isn't requested by overwhelming majority of the users and we don't plan to support it at the nearest time.

Ivo
Posts: 6
Joined: Fri 17 Dec 2004 03:38
Location: Brazil

Post by Ivo » Fri 24 Dec 2004 12:22

Ok.
I have the source code of MyDAC and already changed this behavior.

Thanks

Post Reply