X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7D1643A201D for ; Fri, 14 Jan 2005 21:04:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 17817-01 for ; Fri, 14 Jan 2005 21:03:45 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id E41063A1FE6 for ; Fri, 14 Jan 2005 21:03:46 +0000 (GMT) Received: (qmail 15779 invoked from network); 14 Jan 2005 21:03:13 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 14 Jan 2005 21:03:13 -0000 Message-ID: <41E833B6.9050807@fastcrypt.com> Date: Fri, 14 Jan 2005 16:03:50 -0500 From: Dave Cramer Reply-To: pg@fastcrypt.com Organization: Postgres International User-Agent: Mozilla Thunderbird 1.0 (X11/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "j.random.programmer" Cc: pgsql-jdbc@postgresql.org Subject: Re: Weird behavior in transaction handling (Possible bug ?) References: <20050114195454.70368.qmail@web14226.mail.yahoo.com> In-Reply-To: <20050114195454.70368.qmail@web14226.mail.yahoo.com> Content-Type: multipart/alternative; boundary="------------050905000504030103000502" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.061 tagged_above=0 required=5 tests=AWL, HTML_30_40, HTML_MESSAGE, HTML_TITLE_EMPTY X-Spam-Level: X-Archive-Number: 200501/131 X-Sequence-Number: 12011 This is a multi-part message in MIME format. --------------050905000504030103000502 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit j.random.programmer wrote: >>The first insert does not fail, it is the duplicate >>key of the second >>insert that is the error. >> >> > >It does fail since the commit() failed silently. There >is nothing in the database at all. > > What I meant to say it is not the cause of the error, only the second is the cause of the error now as I said before because one of the statements in the transaction had an error none of the statements in the transaction will commit a transaction is a unit of work, and it is atomic http://www.postgresql.org/docs/7.4/interactive/tutorial-transactions.html as the docs referred to above suggest. > > > >>They read this and will probably not respond because >>they do not >>consider this an error. >> >> > >But it's contrary to what oracle, db2, sybase (I >think) and >mysql/innodb do. > >It's not documented in the postgresql documentation >either >as far as I can tell. > > > >>This is not a silent failure. The insert errored out >>and gave you a >>message. commit is basically just end transaction >>here. >> >> > >But why should a insert error mean that I have to >abort >the entire transaction ? And if so, then the driver >can >warn about that, no ? (especially since the same JDBC >code >runs fine on oracle, db2, mysql/innodb and sybase). >It's >a postgres specific non-documented thing, so >shouldn't >the JDBC driver warn us as to what's going on ? > >Or are you saying that I need to special case JDBC >code >of postgres ? > > > Because transactions in postgresql are ATOMIC. It's all or nothing. How do you handle the case of moving money from one bank account to another ( for example) and the second update fails. ie update bank1 set balance=balance-20; update bank2 set balance=balance+20; Does the money just dissappear ? What if the program can't "fix" the problem. ie the disk is full. I understand you have an investment in your code, but this is the way postgres works, no amount of emails are going to change that fact. >>The user is supposed to handle the errors, not the >>driver. >> >> > >But the error is postgresql specific. There is no >error, only >a insert within a transaction failed. Why should that >affect >the rest of the transaction, if *I* as the user don't >want it to? > > > How does postgres know which parts you don't care about ? Dave >Best regards, > >--j > > > >__________________________________ >Do you Yahoo!? >The all-new My Yahoo! - What will yours do? >http://my.yahoo.com > > > > -- Dave Cramer http://www.postgresintl.com 519 939 0336 ICQ#14675561 --------------050905000504030103000502 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit

j.random.programmer wrote:
The first insert does not fail, it is the duplicate
key of the second 
insert that is the error.
    

It does fail since the commit() failed silently. There
is nothing in the database at all.
  
What I meant to say it is not the cause of the error, only the second is the cause of the error
now as I said before because one of the statements in the transaction had an error none of the statements in the transaction will commit
a transaction is a unit of work, and it is atomic

http://www.postgresql.org/docs/7.4/interactive/tutorial-transactions.html

as the docs referred to above suggest.

 
  
They read this and will probably not respond because
they do not 
consider this an error.
    

But it's contrary to what oracle, db2, sybase (I
think) and 
mysql/innodb do.

It's not documented in the postgresql documentation
either
as far as I can tell.

  
This is not a silent failure. The insert errored out
and gave you a 
message. commit is basically just end transaction
here.
    

But why should a insert error mean that I have to
abort
the entire transaction ? And if so, then the driver
can
warn about that, no ? (especially since the same JDBC
code
runs fine on oracle, db2, mysql/innodb and sybase).
It's
a  postgres specific non-documented thing, so
shouldn't
the JDBC driver warn us as to what's going on ?

Or are you saying that I need to special case JDBC
code
of postgres ?

  
Because transactions in postgresql are ATOMIC. It's all or nothing.

How do you handle the case of moving money from one bank account to another ( for example) and the second update fails.

ie
update bank1 set balance=balance-20;
update bank2 set balance=balance+20;

Does the money just dissappear ?  What if the program can't "fix" the problem. ie the disk is full.

I understand you have an investment in your code, but this is the way postgres works, no amount of emails are going to change that fact.


  
The user is supposed to handle the errors, not the
driver.
    

But the error is postgresql specific. There is no
error, only
a insert within a transaction failed. Why should that
affect
the rest of the transaction, if *I* as the user don't
want it to?

  
How does postgres know which parts you don't care about ?

Dave
Best regards,

--j


		
__________________________________ 
Do you Yahoo!? 
The all-new My Yahoo! - What will yours do?
http://my.yahoo.com 


  

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561
--------------050905000504030103000502--