transaction using fdo-postgis provider

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

transaction using fdo-postgis provider

taiyabali
Hi,
I am new to FDO library and i am using FDO 3.8.0 to connect and perform various operation on my postgresql-9.1 database with postgis2.0 and I need to use Fdo Longtransaction commands for transaction managment.

when i query for the command capabilities-

FdoPtr<FdoIConnectionCapabilities> concap = (FdoIConnectionCapabilities*)m_objFDOConnection->GetCommandCapabilities();
bool supprttransaction = concap->SupportsTransactions();

its giving support as true but when try to create a command

FdoPtr<FdoIActivateLongTransaction> getlongtransaction = (FdoIActivateLongTransaction*)m_objFDOConnection->CreateCommand(FdoCommandType_ActivateLongTransaction);

it gives me  exceptionMessage = "Command not supported "
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

Jackie Ng
SupportsTransactions() means this is allowed:

FdoPtr<FdoITransaction> transaction = m_objFDOConnection->BeginTransaction();

Long Transactions are a completely different thing from regular transactions with a different capability to check for

- Jackie
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

taiyabali
This post was updated on .
Hi jackie,
thanks for helping..
 
but I have multiple create, update and delete operations then which type of transaction should i use simple one or long transactions.

And as per your reply I cheked the BeginTransation function it is not working as well. Do we need to configure anything before using it or Is their a option in FDO to stop the autocommit.
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

Jackie Ng
"Is not working" is not a very useful thing to say to a programmer :)

Long Transactions is an Oracle-ism that does not relate to what you're trying to do. The PostGIS provider does not support Long Transactions so the question is moot.

The FdoITransaction does not autocommit. It requires explicit commit/rollback.

So your code would look something like this

FdoPtr<FdoITransaction> trans = fdoConn->BeginTransaction();
try
{
     //Do your changes here

     //Commit the transaction when done
     trans->Commit();
}
catch (FdoException* ex) //Something went wrong
{
     trans->Rollback();
     ex->Release();
}

- Jackie
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

taiyabali
HI,
I got it. I have reached halfway. I tried the way jackie suggessted and i found that my insert command is sucessfully rollbacked if any exception occurs. But now my issue is I want to club schema modifications and data modification in one transaction i.e i want to club ApplySchema changes and insert update and delete in one transaction. When i am trying to do the same FdoTransaction fails to rollback.

-taiyabali
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

Greg Boone
It seems that this scenario requires you to create and maintain a single context or "manager" object as a global owner of the actions you wish to apply. This manager will execute all of your required actions in the combined scenario you quote below. It will own and initialize the FDO Transaction and manage its state. The Transaction will be maintained for as long as the schema modification/data modification routines are running. If a failure occurs and an exception thrown, catch the exception and have the manager cleanup as required.

Greg

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of taiyabali
Sent: Friday, July 05, 2013 6:42 AM
To: [hidden email]
Subject: Re: [fdo-users] transaction using fdo-postgis provider

HI,
I got it. I have reached halfway. I tried the way jackie suggessted and i found that my insert command is sucessfully rollbacked if any exception occurs. But now my issue is I want to club schema modifications and data modification in one transaction i.e i want to club ApplySchema changes and insert update and delete in one transaction. When i am trying to do the same FdoTransaction fails to rollback.

-taiyabali



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/transaction-using-fdo-postgis-provider-tp5064065p5064281.html
Sent from the FDO Users mailing list archive at Nabble.com.
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

taiyabali
Hi Greg,
Thanks for replying but can you explain the solution little more. I don't know much about FDO I am very new to this API. Are you saying to make a manager class of our own and manage this transaction manually. If that is what you are suggesting then I don't think its a good solution because transactions in database should be managed by database not on client side. If your suggestion is something else Then can you please elaborate it a little more. Thanks

taiyabali
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

Greg Boone
Ok. Then I go back to Jackie's response... It sounds like he described what you need pretty well.

FdoPtr<FdoITransaction> trans = fdoConn->BeginTransaction();

try
{
     //Do your changes here
     bool ret = CallMyApplySchema();
     if (ret)
         CallMyInsertFeatures()

     //Commit the transaction when done
     trans->Commit();
}
catch (FdoException* ex) //Something went wrong
{
     trans->Rollback();
     ex->Release();
}

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of taiyabali
Sent: Monday, July 08, 2013 2:20 AM
To: [hidden email]
Subject: Re: [fdo-users] transaction using fdo-postgis provider

Hi Greg,
Thanks for replying but can you explain the solution little more. I don't know much about FDO I am very new to this API. Are you saying to make a manager class of our own and manage this transaction manually. If that is what you are suggesting then I don't think its a good solution because transactions in database should be managed by database not on client side.
If your suggestion is something else Then can you please elaborate it a little more. Thanks

taiyabali



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/transaction-using-fdo-postgis-provider-tp5064065p5064633.html
Sent from the FDO Users mailing list archive at Nabble.com.
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

taiyabali
Ya this thing i have already tried and the problem i am facing by following that methodology is that once I call the execute method of apply schema command and then if i say rollback it is not getting rollbacked. But if am not doing any schema changes i am just doing insert update and delete it is working fine. So my question is have you ever tried to change the schema (say adding a table) and then do insertion, updation and deletion of entries in one transaction. If yes then how. I doubt whether FDO or postgres provider supports this actions. Please help me ireally need this working.

taiyabali
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

zspitzer
transactions are usually only DML not DDL related?


On Tue, Jul 9, 2013 at 3:41 PM, taiyabali <[hidden email]> wrote:
Ya this thing i have already tried and the problem i am facing by following
that methodology is that once I call the execute method of apply schema
command and then if i say rollback it is not getting rollbacked. But if am
not doing any schema changes i am just doing insert update and delete it is
working fine. So my question is have you ever tried to change the schema
(say adding a table) and then do insertion, updation and deletion of entries
in one transaction. If yes then how. I doubt whether FDO or postgres
provider supports this actions. Please help me ireally need this working.

taiyabali



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/transaction-using-fdo-postgis-provider-tp5064065p5064879.html
Sent from the FDO Users mailing list archive at Nabble.com.
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users



--
Zac Spitzer
+61 405 847 168


_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

taiyabali
Ok then does that mean we cannot have DDL in transaction. But when we write create SQL in a transaction block it works. Are you sure about that because i think transactions should work for DDL and DML both.
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

zspitzer
but I maybe the FDO provider doesn't support it


On Tue, Jul 9, 2013 at 4:39 PM, taiyabali <[hidden email]> wrote:
Ok then does that mean we cannot have DDL in transaction. But when we write
create SQL in a transaction block it works. Are you sure about that because
i think transactions should work for DDL and DML both.



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/transaction-using-fdo-postgis-provider-tp5064065p5064883.html
Sent from the FDO Users mailing list archive at Nabble.com.
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users



--
Zac Spitzer
+61 405 847 168


_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

Jackie Ng
In reply to this post by taiyabali
This is where I'd say you should switch on trace logging for that provider (http://themapguyde.blogspot.com.au/2013/01/mapguide-tidbits-fdo-rdbms-provider.html) and see what kind of SQL is being executed and if it matches what you would normally execute through pgAdmin or any PostgreSQL client admin application.

- Jackie
Reply | Threaded
Open this post in threaded view
|

Re: transaction using fdo-postgis provider

Brent Robinson
Hi,

The PostGIS provider executes DDL statements on a different connection than it does for other statements, which would explain why an ApplySchema cannot be rolled back in an FDO Transaction.

I'm not exactly sure of the reason why but there might have been some situations where a connection gets blocked when a transaction including DDL statements stays open. It may have something to do with the data dictionary tables that a DDL statement updates. Currently, the provider does a commit before every DDL statement, with the following comment:

           // Commit all transactions before issuing a DDL statement; Otherwise the server may block if a transaction is open
            // and accessing a table that may be modified by the DDL statement.

A commit is done on both the DDL and non-DDL connection.

Brent.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Jackie Ng
Sent: Tuesday, July 09, 2013 3:23 AM
To: [hidden email]
Subject: Re: [fdo-users] transaction using fdo-postgis provider

This is where I'd say you should switch on trace logging for that provider
(http://themapguyde.blogspot.com.au/2013/01/mapguide-tidbits-fdo-rdbms-provider.html)
and see what kind of SQL is being executed and if it matches what you would normally execute through pgAdmin or any PostgreSQL client admin application.

- Jackie



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/transaction-using-fdo-postgis-provider-tp5064065p5064898.html
Sent from the FDO Users mailing list archive at Nabble.com.
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users
_______________________________________________
fdo-users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/fdo-users