Re: [HACKERS] message for constraint - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: [HACKERS] message for constraint
Date
Msg-id 200601161954.k0GJsWh19910@candle.pha.pa.us
Whole thread Raw
Responses Re: [HACKERS] message for constraint  (Jaime Casanova <systemguards@gmail.com>)
List pgsql-patches
I have added the following documentation addition to suggest this usage
for constraint names.

---------------------------------------------------------------------------

Jaime Casanova wrote:
> On 1/14/06, Peter Eisentraut <peter_e@gmx.net> wrote:
> > Jaime Casanova wrote:
> > > From time to time people ask me if there is a way to "customize"
> > > messages for constraints so they could be more informative to the
> > > user...
> >
> > What about this?
> >
> > => create table foo (fld int4 constraint "fld must contain positive numbers" check (fld > 0));
> > CREATE TABLE
> > => insert into foo values (-5);
> > ERROR:  new row for relation "foo" violates check constraint "fld must contain positive numbers"
> >
> > --
> > Peter Eisentraut
> > http://developer.postgresql.org/~petere/
> >
>
> ok, i didn't know you can use such names...
>
> --
> regards,
> Jaime Casanova
> (DBA: DataBase Aniquilator ;)
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>                http://www.postgresql.org/docs/faq
>

--
  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
Index: create_table.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/ref/create_table.sgml,v
retrieving revision 1.96
retrieving revision 1.98
diff -c -c -r1.96 -r1.98
*** create_table.sgml    1 Nov 2005 21:09:50 -0000    1.96
--- create_table.sgml    16 Jan 2006 19:53:12 -0000    1.98
***************
***************
*** 293,300 ****
      <term><literal>CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable></literal></term>
      <listitem>
       <para>
!       An optional name for a column or table constraint.  If not specified,
!       the system generates a name.
       </para>
      </listitem>
     </varlistentry>
--- 293,304 ----
      <term><literal>CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable></literal></term>
      <listitem>
       <para>
!       An optional name for a column or table constraint.  If the
!       constraint is violated, the constraint name is present in error messages,
!       so constraint names like <literal>"col must be positive"</> can be used
!       to communicate helpful constraint information to client applications.
!       (Double-quotes are required for constraint names that contain spaces.)
!       If not specified, the system generates a name.
       </para>
      </listitem>
     </varlistentry>

pgsql-patches by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: New pg_dump options: exclude tables/schemas, multiple all, wildcards
Next
From: Jaime Casanova
Date:
Subject: Re: [HACKERS] message for constraint