locking problem in 5.50 (urgent)

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

locking problem in 5.50 (urgent)

Post by jkuiper » Fri 03 Oct 2008 14:45

I have a serious problem regarding the lock mechanism in version 5.50.
I didn't notice it before, because the last few weeks I'm developing on printing reports and use only selects and inserts.

This is What I do

Code: Select all

procedure TDM.MyQuery1AfterCancel(DataSet: TDataSet);
var MyQuery : TMyQuery;
begin
  MyQuery := (DataSet as TMyQuery);
  if MyQuery.Connection.InTransaction then
    MyQuery.Connection.Rollback;
end;

procedure TDM.MyQuery1AfterPost(DataSet: TDataSet);
var MyQuery : TMyQuery;
begin
  MyQuery := (DataSet as TMyQuery);
  if MyQuery.Connection.InTransaction then
  begin
    MyQuery.Connection.Commit;
  end;
end;

procedure TDM.MyQuery1BeforeEdit(DataSet: TDataSet);
var MyQuery : TMyQuery;
begin
  MyQuery := (DataSet as TMyQuery);
  if not MyQuery.Connection.InTransaction then
    MyQuery.Connection.StartTransaction;
  MyQuery.Lock(lrImmediately);
  MyQuery.RefreshRecord;
end;

When I edit a record, my application immediately comes with the message "record is locked by another user".
If I edit the same record in "MySQL browser", it works without problems.

Now I downgraded to MyDAC 5.20 and the problem doesn't occur.

Please correct this error, before we're going to D2009

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Mon 06 Oct 2008 12:53

We could not reproduce this problem. Please specify the full version of MyDAC and try the latest version - 5.50.0.39. If it is possible compose a small sample to reproduce the problem.

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Wed 08 Oct 2008 09:45

Problem occurred in version 5.50.0.36.
I've installed the latest version and solved the problem.
Thanks. :D

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Wed 08 Oct 2008 12:26

Maybe I was in a hurry, but the problem is participially solved.
Now I can edit my record, but when I want to re-edit the record, my application says: "Record was changed by another user."
This problem does not occur in version 5.20.1.15.
You can find the problen in procedure beforepost();

I have sent an example to dmitryg*devart*com

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 10 Oct 2008 14:45

On executing Lock(lrImmediately) a query is executed to MySQL Server and all fields are compared with current values of a record. But the problem is that when you use the AsDateTime property to set a field value, the exact date (with milliseconds) is stored on the server in format YYYY-MM-DD HH:NN:SS (without milliseconds). Therefore in this case value on client differs from server's by milliseconds.
In order to solve this problem you should use the following code to set the TDateTimeField value:

Code: Select all

  MyQuery.FieldByName('updatedate').AsString := DateTimeToStr(now);

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Fri 10 Oct 2008 14:59

I shall install the latest version of MyDAC.
But what I don't understand, version 5.20.1.15 is working without any problems (see the executables sent by email).

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Sun 12 Oct 2008 12:58

I tested it with version 5.55.x with the option datetostr().
That works as a workaround and is not really a option for us. We're using the now function, so that we can perfectly see when the record has been inserted / updated. DateToStr() is only insert /update the date.
I don't see the reason why it shouldn't work. This is really a time issue in MyDAC and not in MySQL. If I update the record in version 5.20.1.15 it's no problem to use the now function (see my example nawdemo520.exe and nawdemo555.exe)
You changed something in the locking procedure that isn't right.

We really want to fix this error. I think it is as serious one. If people uses records with time issues and locking should be having the same problems.

Challenger
Devart Team
Posts: 925
Joined: Thu 17 Nov 2005 10:53

Post by Challenger » Mon 13 Oct 2008 09:27

The changes that were made in locking procedure are correct. The record should be checked for any changes before locking. In this case the problem is in date fields comparison. We will fix this in the next build of MyDAC.

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Mon 13 Oct 2008 13:14

Thanks :D :D

siberya
Posts: 23
Joined: Thu 23 Mar 2006 19:00

i have found this problem

Post by siberya » Sat 01 Nov 2008 02:38

MemUtils.pas VarEqual function wrong. Check this lines.

if ((VarType(Value1) = varOleStr) or (VarType(Value1) = varString)) and (Value1 = '') then
Result := False
else
if ((VarType(Value2) = varOleStr) or (VarType(Value2) = varString)) and (Value2 = '') then
Result := False

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 04 Nov 2008 09:27

Thank you for information. We have fixed this problem. This fix will be included in the next MyDAC build.

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Tue 11 Nov 2008 08:18

Is this problem already solved? I'm using mydac 5.70.0.41 and the problem still exists.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 13 Nov 2008 09:17

The MyDAC build where this problem is solved will be released in the course of the next week.

jkuiper
Posts: 138
Joined: Fri 04 Aug 2006 14:17

Post by jkuiper » Fri 21 Nov 2008 08:39

Just dowloaded MyDAC 5.70.0.42 and installed it.
As far as I could see, the record problem is solved :D

Thanks.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 21 Nov 2008 09:58

I am happy that this problem has been solved. If any other questions come up, please contact me.

Post Reply