Re: error code with psql

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: error code with psql
Date: 2004-05-06 03:13:15
Message-ID: 200405060313.i463DFx14672@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tatsuo Ishii wrote:
> Hi,
>
> Does anybody know how I can get error codes using psql? I know that I
> could get error codes from server log or using libpq function. I just
> could not figure out a way to display them in psql.

Sure. With psql, you need to set the VERBOSITY setting for psql to
access those error codes:

test=> CREATE TABLE test (x int UNIQUE);
NOTICE: CREATE TABLE / UNIQUE will create implicit index "test_x_key"
for table "test"
CREATE TABLE

test=> INSERT INTO test VALUES (1);
INSERT 17225 1
test=> INSERT INTO test VALUES (1);
ERROR: duplicate key violates unique constraint "test_x_key"

test=> \set VERBOSITY 'verbose'
test=> INSERT INTO test VALUES (1);
--> ERROR: 23505: duplicate key violates unique constraint "test_x_key"
LOCATION: _bt_check_unique, nbtinsert.c:255

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jan Wieck 2004-05-06 03:30:11 Re: [GENERAL] cache lookup of relation 165058647 failed
Previous Message Tatsuo Ishii 2004-05-06 03:08:01 Re: error code with psql