Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 09E06B5DD87 for ; Wed, 7 Sep 2011 18:46:42 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 47605-01-9 for ; Wed, 7 Sep 2011 21:46:35 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail148113.authsmtp.com (outmail148113.authsmtp.com [62.13.148.113]) by mail.postgresql.org (Postfix) with ESMTP id 39490B5FDFD for ; Wed, 7 Sep 2011 18:31:46 -0300 (ADT) Received: from mail-c194.authsmtp.com (mail-c194.authsmtp.com [62.13.128.121]) by punt10.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id p87LVfp7014263; Wed, 7 Sep 2011 22:31:41 +0100 (BST) Received: from asuka.2ndquadrant.com (85-220-53-71.dsl.dynamic.simnet.is [85.220.53.71]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2) with ESMTP id p87LVZhV046981; Wed, 7 Sep 2011 22:31:36 +0100 (BST) To: Kris Jurka Cc: PostgreSQL JDBC Subject: Re: Patch: Some more state codes References: From: "Johann 'Myrkraverk' Oskarsson" Date: Wed, 07 Sep 2011 21:31:34 +0000 In-Reply-To: (Kris Jurka's message of "Wed, 7 Sep 2011 12:30:01 -0400 (EDT)") Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.19 (usg-unix-v) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Server-Quench: c402d1eb-d998-11e0-80b9-0022640b883e X-AuthReport-Spam: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-AuthRoute: OCdxZQATClZXSwQT DCUsVilMUBgsKgdF BwNFJgxfNl8UURhQ KkJXbgASJgVDAmpU Q3kJW1VVQF9zU2B0 YQlXIw1YfEhMXxtv U1ZOQ01QEQdtHhxP RhYZLn8YL2NGfHh5 bUcsWHJTVAopcUZ/ Fk8BR3BSbG5odWEe BUBFfwMGeR5Kfh1H bFR/BnsFYjBJBC9q VzwRExoaCH1nIThe QlNFFlUXTA4OGSQx DwseFCkiVUYCSygo RwAA X-Authentic-SMTP: 61633235383639.1015:706 X-AuthFastPath: 255 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/15 X-Sequence-Number: 22133 Kris Jurka writes: > On Wed, 7 Sep 2011, Johann 'Myrkraverk' Oskarsson wrote: > >> Here are some more state codes. > > But what's the gain? This isn't supposed to be a master list of > every possible state code (and this patch doesn't try to do that > either). What's the point of adding some new codes that no one is > using? Well, for application use imagine this scenario (from an actual application of mine): Pseudocode: try { CREATE TABLE t ... } catch ( SQLException e ) { if ( e.getSQLState().equals( PSQLState.DUPLICATE_TABLE ) ) ; // do something or ignore when the table exists already ... } Similarly: try { INSERT INTO t ... } catch ( SQLException e ) { if ( e.getSQLState().equals( PSQLState.UNDEFINED_TABLE ) ) ; // possibly call the code above, or handle otherwise ... } Those are not from the actual application, just examples. Now, if you don't want applications to use PSQLState and rely on the numerical values then there is not much need, no. The UNDEFINED_OBJECT constant is a little trickier. I use it to patch the driver for the Atomikos XA testsuite. I've already submitted that patch but do understand your reluctance to accept it since its validity is not immediately apparent. I'll quote Guy from Atomikos: Scenario: 1-transaction manager starts transaction 2-application does some SQL and returns ok 3-application requests commit 4-transaction manager sends prepare to Postgresql 5-postgresql server fails before receiving prepare 6-transaction manager assumes the worst and attempts/retries rollback 7-postgresql comes back up, recovers without the (unprepared) transaction 8-postgresql receives unknown xid from the transaction manager retrying rollback By convention, if the DBMS does not remember a transaction it must have been rolled back (underpinning of XA). Rollback is idempotent so there is no reason why step 8 should fail. It can be silently ignored by the DBMS and the transaction outcome will still be along the expected lines (rollback = no effects on data). This means that when the XA driver rolls back and the error code is UNDEFINED_OBJECT the error should be ignored. -- Johann Oskarsson http://www.2ndquadrant.com/ |[] PostgreSQL Development, 24x7 Support, Training and Services --+-- | Blog: http://my.opera.com/myrkraverk/blog/