Re: [HACKERS] Does psql use nested transactions?

2004-08-19 Thread Oliver Elphick
On Wed, 2004-08-18 at 02:48, Greg Stark wrote: Simon Riggs [EMAIL PROTECTED] writes: This behaviour allows much closer mimicking of Oracle and other RDBMS's transactional behaviour begin 2cThis is my single biggest pet peeve with Postgres. When I was first starting it was the single

Re: [HACKERS] Does psql use nested transactions?

2004-08-18 Thread Honza Pazdziora
On Tue, Aug 17, 2004 at 02:56:19PM -0400, Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: Doing it only for interactive mode seems too error-prone to me (it works in psql, but not from my script). You're missing the point: a script cannot safely work this way. A human typing at

Re: [HACKERS] Does psql use nested transactions?

2004-08-18 Thread Christopher Kings-Lynne
It is not just a typo that you make in the SQL command. You often need to do insert into table which has primary key if the insert failed, do update of the existing record Do the update first then the insert. Chris ---(end of

Re: [HACKERS] Does psql use nested transactions?

2004-08-18 Thread Honza Pazdziora
On Wed, Aug 18, 2004 at 02:47:26PM +0800, Christopher Kings-Lynne wrote: It is not just a typo that you make in the SQL command. You often need to do insert into table which has primary key if the insert failed, do update of the existing record Do the update first then the

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Bruce Momjian
Philip Warner wrote: At 01:47 AM 12/08/2004, Tom Lane wrote: It might be reasonable to offer that behavior as an option, but I think I'd only want it on for interactive input. My preference would be for something like: set savepoint_per_statement=true then interactive scripts

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Tom Lane
Bruce Momjian [EMAIL PROTECTED] writes: Added to TODO list: * Add an option to automatically use savepoints for each statement in a multi-statement transaction. When enabled, this would allow errors in multi-statement transactions to be automatically ignored. Note that whoever

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Gaetano Mendola
Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: Added to TODO list: * Add an option to automatically use savepoints for each statement in a multi-statement transaction. When enabled, this would allow errors in multi-statement transactions to be automatically ignored. Like I said, my

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Haroldo Stenger
Hi Tom On Wed, 11 Aug 2004 11:47:35 -0400, Tom Lane [EMAIL PROTECTED] wrote: The other objection is that this would create very substantial overhead. why? It might be reasonable to offer that behavior as an option, but I think I'd only want it on for interactive input. How could the server

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Bruce Momjian
Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: Added to TODO list: * Add an option to automatically use savepoints for each statement in a multi-statement transaction. When enabled, this would allow errors in multi-statement transactions to be automatically ignored.

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Tom Lane
Haroldo Stenger [EMAIL PROTECTED] writes: On Wed, 11 Aug 2004 11:47:35 -0400, Tom Lane [EMAIL PROTECTED] wrote: It might be reasonable to offer that behavior as an option, but I think I'd only want it on for interactive input. How could the server tell interactive input from scripted intput

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Tom Lane
Bruce Momjian [EMAIL PROTECTED] writes: Doing it only for interactive mode seems too error-prone to me (it works in psql, but not from my script). You're missing the point: a script cannot safely work this way. A human typing at the terminal can notice that his command failed and react to

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Simon Riggs
Bruce Momjian Tom Lane wrote: Bruce Momjian [EMAIL PROTECTED] writes: Added to TODO list: * Add an option to automatically use savepoints for each statement in a multi-statement transaction. When enabled, this would allow errors in multi-statement transactions to be

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Alvaro Herrera Munoz
On Tue, Aug 17, 2004 at 03:33:01PM -0300, Haroldo Stenger wrote: Haroldo, On Wed, 11 Aug 2004 11:47:35 -0400, Tom Lane [EMAIL PROTECTED] wrote: The other objection is that this would create very substantial overhead. why? Establishing a savepoint is a non-trivial operation (cost-wise).

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Tom Lane
Alvaro Herrera Munoz [EMAIL PROTECTED] writes: Establishing a savepoint is a non-trivial operation (cost-wise). Several internal server structures have to be prepared for it. Check It's way cheaper than normal transaction start and commit, Is it? You have the same amount of work to do

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Haroldo Stenger
Hola Alvaro On Tue, 17 Aug 2004 16:58:56 -0400, Alvaro Herrera Munoz [EMAIL PROTECTED] wrote: On Wed, 11 Aug 2004 11:47:35 -0400, Tom Lane [EMAIL PROTECTED] wrote: The other objection is that this would create very substantial overhead. why? Establishing a savepoint is a non-trivial

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Philip Warner
At 07:10 AM 18/08/2004, Tom Lane wrote: I have not had an opportunity to benchmark it but I fear a savepoint may cost near as much as a full xact in practice. Out of curiosity, does this mean that using a savepoint per statement will be no worse than using psql in autocommit mode?

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Philip Warner
At 04:44 AM 18/08/2004, Bruce Momjian wrote: it turns off when the transaction completes? Not sure I like this part; I would like to be able to set the variable at the start of a psql session and have it run for the entire session. Or, even better, set it in a psql initialization file. Also,

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Philip Warner
At 09:26 AM 18/08/2004, Philip Warner wrote: Also, will the 'interactive-session' check consider an included file (\i) to be interactive? I'd vote yes. In retrospect, I assume the interactive-session limit would not be a problem here since the command would be entered interactively. The source

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Alvaro Herrera
On Tue, Aug 17, 2004 at 08:21:13PM -0300, Haroldo Stenger wrote: Hola, On Tue, 17 Aug 2004 16:58:56 -0400, Alvaro Herrera Munoz [EMAIL PROTECTED] wrote: Establishing a savepoint is a non-trivial operation (cost-wise). Several internal server structures have to be prepared for it. It's

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Alvaro Herrera
On Wed, Aug 18, 2004 at 09:23:44AM +1000, Philip Warner wrote: At 07:10 AM 18/08/2004, Tom Lane wrote: I have not had an opportunity to benchmark it but I fear a savepoint may cost near as much as a full xact in practice. Out of curiosity, does this mean that using a savepoint per statement

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Greg Stark
Simon Riggs [EMAIL PROTECTED] writes: This behaviour allows much closer mimicking of Oracle and other RDBMS's transactional behaviour begin 2cThis is my single biggest pet peeve with Postgres. When I was first starting it was the single most frustrating violation of the least surprise

Re: [HACKERS] Does psql use nested transactions?

2004-08-17 Thread Dennis Bjorklund
On 17 Aug 2004, Greg Stark wrote: With Postgres I effectively have to work in autocommit mode. Starting over from scratch every time I make a typo is infeasible. It feels like trying to type in a C program using cat. I've done it before but it's not something I want to repeat often. I agree.

[HACKERS] Does psql use nested transactions?

2004-08-11 Thread Philip Warner
In 8.0 beta 1 I just tried: psql template1 begin; select * from pg_class; ... got stuff ... select * from aaa; ERROR: relation zzz does not exist select * from pg_class; ERROR: current transaction is aborted Should psql run every statement in a nested

Re: [HACKERS] Does psql use nested transactions?

2004-08-11 Thread Merlin Moncure
In 8.0 beta 1 I just tried: psql template1 begin; select * from pg_class; ... got stuff ... select * from aaa; ERROR: relation zzz does not exist select * from pg_class; ERROR: current transaction is aborted Should psql run every

Re: [HACKERS] Does psql use nested transactions?

2004-08-11 Thread Philip Warner
At 01:47 AM 12/08/2004, Tom Lane wrote: It might be reasonable to offer that behavior as an option, but I think I'd only want it on for interactive input. My preference would be for something like: set savepoint_per_statement=true then interactive scripts could choose to use either feature.

Re: [HACKERS] Does psql use nested transactions?

2004-08-11 Thread Tom Lane
Should psql run every statement in a nested transaction and only rollback that TX? psql is designed to follow the same logical statement progression as any other connection to the database. Your suggestion could muck up sql scripts piped through it to the database. The other objection is