Re: Problem with Check Constraint in pg_restore - Mailing list pgsql-general

From Tom Lane
Subject Re: Problem with Check Constraint in pg_restore
Date
Msg-id 22666.1247494016@sss.pgh.pa.us
Whole thread Raw
In response to Problem with Check Constraint in pg_restore  (Alan Millington <admillington@yahoo.co.uk>)
Responses Re: Problem with Check Constraint in pg_restore
List pgsql-general
Alan Millington <admillington@yahoo.co.uk> writes:
> CONSTRAINT "RP_DATE_check" CHECK (date IS NULL AND accuracy = '?'::bpchar OR date IS NOT NULL AND date >
'1099-12-31'::dateAND (accuracy = 'D'::bpchar OR accuracy = 'M'::bpchar AND date::text ~~ '%-01'::text OR (accuracy =
'Y'::bpcharOR 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

pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Request for features
Next
From: Marek Lewczuk
Date:
Subject: Re: SPI_ERROR_CONNECT within pl/pgsql, PG 8.4