Re: Problem with Check Constraint in pg_restore

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alan Millington <admillington(at)yahoo(dot)co(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Problem with Check Constraint in pg_restore
Date: 2009-07-13 14:06:56
Message-ID: 22666.1247494016@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Alan Millington <admillington(at)yahoo(dot)co(dot)uk> writes:
> CONSTRAINT "RP_DATE_check" CHECK (date IS NULL AND accuracy = '?'::bpchar OR date IS NOT NULL AND date > '1099-12-31'::date AND (accuracy = 'D'::bpchar OR accuracy = 'M'::bpchar AND date::text ~~ '%-01'::text OR (accuracy = 'Y'::bpchar OR accuracy = '?'::bpchar) AND date::text ~~ '%-01-01'::text))

These ~~ (LIKE) tests on date columns seem horribly unsafe. I suspect
your problem is that you're trying to load the data with DateStyle
set to some setting other than what this constraint is hard-wired
to assume. Personally I'd suggest replacing the LIKEs with something
using EXTRACTs, or some other way that doesn't depend on the textual
formatting of dates.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Fetter 2009-07-13 14:32:20 Re: Start With... Connect By?
Previous Message Richard Broersma 2009-07-13 13:55:34 Re: LAPUG Social - Tuesday Evening July 14