Page 1 of 2

locking problem in 5.50 (urgent)

Posted: Fri 03 Oct 2008 14:45
by jkuiper
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

Posted: Mon 06 Oct 2008 12:53
by Challenger
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.

Posted: Wed 08 Oct 2008 09:45
by jkuiper
Problem occurred in version 5.50.0.36.
I've installed the latest version and solved the problem.
Thanks. :D

Posted: Wed 08 Oct 2008 12:26
by jkuiper
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

Posted: Fri 10 Oct 2008 14:45
by Dimon
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);

Posted: Fri 10 Oct 2008 14:59
by jkuiper
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).

Posted: Sun 12 Oct 2008 12:58
by jkuiper
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.

Posted: Mon 13 Oct 2008 09:27
by Challenger
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.

Posted: Mon 13 Oct 2008 13:14
by jkuiper
Thanks :D :D

i have found this problem

Posted: Sat 01 Nov 2008 02:38
by siberya
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

Posted: Tue 04 Nov 2008 09:27
by Dimon
Thank you for information. We have fixed this problem. This fix will be included in the next MyDAC build.

Posted: Tue 11 Nov 2008 08:18
by jkuiper
Is this problem already solved? I'm using mydac 5.70.0.41 and the problem still exists.

Posted: Thu 13 Nov 2008 09:17
by Dimon
The MyDAC build where this problem is solved will be released in the course of the next week.

Posted: Fri 21 Nov 2008 08:39
by jkuiper
Just dowloaded MyDAC 5.70.0.42 and installed it.
As far as I could see, the record problem is solved :D

Thanks.

Posted: Fri 21 Nov 2008 09:58
by Dimon
I am happy that this problem has been solved. If any other questions come up, please contact me.