Re: error code with psql

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: error code with psql
Дата
Msg-id 200405060313.i463DFx14672@candle.pha.pa.us
обсуждение исходный текст
Ответ на error code with psql  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Список 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@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

В списке pgsql-general по дате отправления:

Предыдущее
От: Tatsuo Ishii
Дата:
Сообщение: Re: error code with psql
Следующее
От: "Ed L."
Дата:
Сообщение: select for update & lock contention