X-Original-To: pgsql-interfaces@postgresql.org Received: from localhost (unknown [64.117.224.193]) by developer.postgresql.org (Postfix) with ESMTP id D2F43923575 for ; Thu, 22 May 2003 18:33:36 -0400 (EDT) Received: from developer.postgresql.org ([64.117.224.193]) by localhost (developer.postgresql.org [64.117.224.193:10024]) (amavisd-new) with ESMTP id 68600-08 for ; Thu, 22 May 2003 18:33:05 -0400 (EDT) Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) by developer.postgresql.org (Postfix) with ESMTP id E0229923384 for ; Thu, 22 May 2003 16:58:33 -0400 (EDT) Received: from luna.lyris.com (luna.lyris.com [216.91.57.116]) by luna.lyris.com (8.12.8/8.12.8) with SMTP id h4MKwIw2023809 for ; Thu, 22 May 2003 13:58:18 -0700 Received: from forest (forest.lyris.com [216.91.56.45]) by luna.lyris.net with SMTP (MailShield v2.04 - LINUX Jul 17 2001 16:58:31); Thu, 22 May 2003 13:58:18 -0700 From: Forest Wilkinson To: pgsql-interfaces@postgresql.org Subject: PGRES_FATAL_ERROR from queries in transaction abort state? Date: Thu, 22 May 2003 13:58:10 -0700 Message-ID: X-Mailer: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-SMTP-HELO: forest X-SMTP-MAIL-FROM: lyris-pg@tibit.com X-SMTP-RCPT-TO: pgsql-interfaces@postgresql.org X-SMTP-PEER-INFO: forest.lyris.com [216.91.56.45] X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/49 X-Sequence-Number: 4167 I am maintaining code that uses libpq, and takes PGRES_FATAL_ERROR to mean the database connection can no longer be used. However, this does not appear to be true in all cases. I have found that PGRES_FATAL_ERROR is returned by all queries within a transaction after any previous query fails. Unfortunately, I have no good way to distinguish this situation (which merely requires a ROLLBACK) from an actual fatal error. I don't want to parse the text from PQresultErrorMessage(), because I don't believe it's guaranteed to remain consistent between versions and locales. Is there another way to tell the difference? Why isn't PGRES_NONFATAL_ERROR returned for queries in an aborted transaction state? PGRES_FATAL_ERROR seems like a lie, since the error is not fatal.