UniDac 6.4.16: Problem with InTransaction and AssignConnect

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
invent
Posts: 92
Joined: Tue 16 Jun 2009 10:59
Location: Bielefeld, Germany

UniDac 6.4.16: Problem with InTransaction and AssignConnect

Post by invent » Thu 19 Jan 2017 15:46

Hello,

after the Update from UniDac 4.5.9 to 6.4.16 I cannot use the same UniConnection in EXE und DLL.

In my DLLs I use TUniConnection.AssignConnect

This works fine in UniDac 4.5.9. The Error-Message in 6.4.16 is:

"Can't perform operation on active transaction".

I'm sure there is no active transaction.

So I made some Tests:

After MyUniConnection.Connect the property MyUniConnection.InTransaction is false.

Then I opened a small table. MyUniTable.Open sets MyUniConnection.InTransaction = true.

Another example: UniConnection1.GetTableNames sets MyUniConnection.InTransaction = true.

How can this be? Only Table.Open or GetTablenames cannot start a transaction.

What shall I do?

Kind regards,
Gerd Brinkmann
invent GmbH

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect

Post by ViktorV » Fri 20 Jan 2017 08:58

InterBase/Firebird requires an active transaction for any operation with data, even for opening dataset. Therefore, when calling TUniQuery.Open or TUniConnection.GetTableNames, it is verified if a transaction associated with it is running and, if it is not so - it is automatically run. In your example dataset uses a default transaction TUniConnection, therefore when attempting to call the Connection.StartTransaction method, you get the "Can't perform operation on active transaction" error, because when opening dataset the transaction has already started.
To solve the issue you can use the following advice:
- use for dataset a separate transaction, not a default transaction TUniConnection;
- use for data modification UpdateTransaction.
The point is, that in UniDAC since version 5.0.1 we added the DefaultTransaction transaction property. All datasets that use the TUniConnection component, use its DefaultTransaction for all operations under data. We added the property because a lot of our users asked us to do it.
In earlier UniDAC versions, all the datasets that used TUniConnection, used implicitly created internal transaction. This transaction always remained open, and it was not possible to control it.
In order to provide backward compatibility with older UniDAC versions, we added the OldTransactionBehaviour global variable declared in "Uni.pas". The default variable value is "False". So, if you want to have old behaviour, you should set the variable to "True".

invent
Posts: 92
Joined: Tue 16 Jun 2009 10:59
Location: Bielefeld, Germany

Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect

Post by invent » Fri 20 Jan 2017 11:11

Hello Viktor,
thanks for this information. Unfortunately that won't solve my case with AssignConnect.

Code: Select all

MyUniConnection1.Connect;
MyUniConnection2.AssignConnect(MyUniConection1);
That works.

Code: Select all

MyUniConnection1.Connect;
MyUniConnection1.GetTableNames (...);
MyUniConnection2.AssignConnect(MyUniConection1);
That gives an error.

So, how can I use AssignConnect?

Kind regards,
Gerd Brinkmann
invent GmbH

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect

Post by ViktorV » Fri 20 Jan 2017 12:22

Thank you for the information. We have reproduced the issue and investigation is in progress. We will inform you when we have any results.

invent
Posts: 92
Joined: Tue 16 Jun 2009 10:59
Location: Bielefeld, Germany

Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect

Post by invent » Mon 23 Jan 2017 14:36

Thanks. I hope you will find a solution.

Until then I made a workaround:

Code: Select all

MyUniConnection1.Connect;
MyUniConnectionTemp.AssignConnect(MyUniConection1);
MyUniConnection1.GetTableNames (...);
MyUniConnection2.AssignConnect(MyUniConectionTemp);
It's not nice, but it works.

Kind regards,
Gerd Brinkmann
invent GmbH

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: UniDac 6.4.16: Problem with InTransaction and AssignConnect

Post by ViktorV » Tue 24 Jan 2017 08:53

We have fixed this issue, the fix will be included in the next UniDAC build.

Post Reply