Default value of column not respecting character length or domain restraints.

From: "Justin Dearing" <zippy1981(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Default value of column not respecting character length or domain restraints.
Date: 2007-03-31 22:36:30
Message-ID: 5458db3c0703311536g9599587r4562c4a3f6979f7f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It seems I can feed a default value to a domain that won't fit in the
underlying base type. I have the domain html_colors as so:

CREATE DOMAIN html_color AS char(7) CHECK (VALUE ~ '^#[A-Fa-f0-9]{6}$');

I then defined a column of html_colors as so:
ALTER TABLE users ALTER COLUMN profile_color SET DEFAULT '#FFFFRFF';

This worked fine and I didn't notice it until I added arecord to the
users table and got the error:
ERROR: value too long for type character(7).

This behavior seems undesirable to me. Is this a known bug or is there
a reason for this?

Regards,
Justin Dearing

Responses

Browse pgsql-general by date

  From Date Subject
Next Message MaDog 2007-03-31 22:40:56 PlPg/SQL
Previous Message Brian A. Seklecki 2007-03-31 21:30:51 Re: Instalation problem