473,387 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Autonomous transaction

Hi, knowing that "autonomous transaction" (Oracle
concept of) are not yet implemented in PostgreSQL, has
anyone found a work-around. I need to preserve
database states from a potential rollback and then log
them inside database tables.

What about:

1) using memory structures to hold the info, then
commit to the database just before exit (after the
rollback occurred).
2) write to the file system, then extract and then
commit to the database just before exit (after the
rollback occurred).
3) send messages to a daemon/database job that will
write to the tables using another
connection/transaction ???
4) ....

Any comment/suggestion would be greatly appreciated.

Note: I am using PostgreSQL 7.4.3 on Linux.

Thanks,

Daniel

__________________________________________________ ____________________
Post your free ad now! http://personals.yahoo.ca

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #1
4 3654
My understanding is that this feature won't be available even in v8 of
postgres. Nested transactions will roll back with the main transaction
when it's rolled back...

You could take a look at contrib/dblink because apparantly you can open
a connection to another (and probably the same) DB, and then write
your logging information that way (ie within a function or session).
Anything you do using the dblink will not be rolled back.

Although I haven't used it, I don't think that dblink is not as simple
to use as Oracle's database link with the "@dblink" notation. So you'll
need to check the docs to see how it works - the README looks OK though.

Maybe someone else can suggest a better approach?

John Sidney-Woollett

Daniel Daoust wrote:
Hi, knowing that "autonomous transaction" (Oracle
concept of) are not yet implemented in PostgreSQL, has
anyone found a work-around. I need to preserve
database states from a potential rollback and then log
them inside database tables.

What about:

1) using memory structures to hold the info, then
commit to the database just before exit (after the
rollback occurred).
2) write to the file system, then extract and then
commit to the database just before exit (after the
rollback occurred).
3) send messages to a daemon/database job that will
write to the tables using another
connection/transaction ???
4) ....

Any comment/suggestion would be greatly appreciated.

Note: I am using PostgreSQL 7.4.3 on Linux.

Thanks,

Daniel

__________________________________________________ ____________________
Post your free ad now! http://personals.yahoo.ca

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #2
At 11:18 AM -0400 9/13/04, Daniel Daoust wrote:
Hi, knowing that "autonomous transaction" (Oracle
concept of) are not yet implemented in PostgreSQL, has
anyone found a work-around. I need to preserve
database states from a potential rollback and then log
them inside database tables.


What I use for this is multiple DB connections. A rollback on one
connection doesn't (generally) affect any of the other connections,
so you can keep things separate and safe from rollbacks.

Note that you can deadlock yourself this way.
--
Dan

--------------------------------------it's like this-------------------
Dan Sugalski even samurai
da*@sidhe.org have teddy bears and even
teddy bears get drunk

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 23 '05 #3
Daniel Daoust <da********@yahoo.ca> writes:
Hi, knowing that "autonomous transaction" (Oracle
concept of) are not yet implemented in PostgreSQL, has
anyone found a work-around. I need to preserve
database states from a potential rollback and then log
them inside database tables.
Postgres goes to great lengths to ensure this is impossible :)
What about:

1) using memory structures to hold the info, then
commit to the database just before exit (after the
rollback occurred).
Well this option in your application layer is how I would do it as it's the
simplest. However:
3) send messages to a daemon/database job that will
write to the tables using another
connection/transaction ???


This option is doable entirely in the database if that's your goal. You can do
this using dblink which is the contrib directory.

It would probably be quite simple to implement, though the most complex in
another sense. With twice as many connections it could be hard to determine
where slowdowns are starting for example. And Better make sure your error
logging connections don't trigger any errors...

--
greg
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #4
> You could take a look at contrib/dblink because
apparantly you can open
a connection to another (and probably the same)
DB, and then write
your logging information that way (ie within a
function or session).
Anything you do using the dblink will not be rolled
back.


Superb! It took me a little while to get it to work
but ‘dblink’ does perfectly what I need it for and
more.

Thanks so much John and, to everyone else.

Daniel Daoust

__________________________________________________ ____________________
Post your free ad now! http://personals.yahoo.ca

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: noah | last post by:
Does PHP have a feature to associate Cookie sessions with a persistent database connection that will allow a single transaction across multiple HTTP requests? Here is how I imagine my process: I...
2
by: Sam | last post by:
Guys, I have a question regarding oracle. I have a stored procedure executing a number of statements including delete , select and lots of inserts in one big procedure and main transaction I...
1
by: Dan Loomis | last post by:
Hi guys - I have a weird condition here I'm trying to get resolution on, and unfortunately I'm not getting anywhere with my friends at Oracle. I'm hoping it's something simple, or at the very...
1
by: Avanish Pandey | last post by:
Hello All We have 3 differen services (in 3 different server) Service A,B,C . We want to implement distributed transaction when call methods of B and C from A. Is it possible? if yes then how? ...
2
by: John Lee | last post by:
Hi, I have few questions related to .NET 2.0 TransactionScope class behavior: 1. Check Transaction.Current.TransactionInformation.DistributedIdentifier to identify if distributed transaction...
15
by: Zeng | last post by:
Hi, The bigger my C# web-application gets, the more places I need to put in the tedious retrying block of code to make sure operations that can run into database deadlocks are re-run (retried)...
1
by: Matik | last post by:
Hi to all, Probably I'm just doing something stupid, but I would like you to tell me that (if it is so), and point the solution. There ist the thing: I' having a sp, where I call other sp...
5
by: dilippanda | last post by:
Hi Experts, I want to know what is the use of pragma autonomous transaction in PL/SQL. In which condition should we use this? Please guide me with an example. Thanks, Dilip
1
AdusumalliGopikumar
by: AdusumalliGopikumar | last post by:
Where we can't use Autonomous transaction?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.