Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Tom Lane
Robert Haas writes: > On Wed, Jun 30, 2010 at 6:57 PM, Tom Lane wrote: >> The detailed definition is amazingly laborious and yet limited, though, >> as it basically doesn't address the problem except for that specific >> case and close relatives. > Well, solving the problem in general is equival

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Chris Browne
mag...@hagander.net (Magnus Hagander) writes: >> I concur with the thought that the most useful solution might be a way >> to tell pg_restore to remove or disable check constraints. > > Uh, say what? Are you saying pg_restore should actually remove > something from the database schema? And thus no

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Robert Haas
On Wed, Jun 30, 2010 at 6:57 PM, Tom Lane wrote: > Peter Eisentraut writes: >> >> "The shall simply contain a > expression> that is retrospectively deterministic." > >> This is then defined in a rather complex manner that ends up disallowing >> col > now() but allowing col < now(). >> > > Oh,

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Tom Lane
Peter Eisentraut writes: > > "The shall simply contain a expression> that is retrospectively deterministic." > This is then defined in a rather complex manner that ends up disallowing > col > now() but allowing col < now(). > Oh, cute. Seems to have been added in SQL:2003. I guess somebody

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Peter Eisentraut
On ons, 2010-06-30 at 10:38 -0400, Tom Lane wrote: > Magnus Hagander writes: > > Shouldn't we disallow anything that's not IMMUTABLE in a check constraint? > > I think you'd get too many howls of pain ... also, such a restriction is > likely contrary to SQL spec. "The shall simply contain a t

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Magnus Hagander
On Wed, Jun 30, 2010 at 20:13, Tom Lane wrote: > Magnus Hagander writes: >> On Wed, Jun 30, 2010 at 19:16, Tom Lane wrote: >>> I concur with the thought that the most useful solution might be a way >>> to tell pg_restore to remove or disable check constraints. > >> Uh, say what? Are you saying p

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Tom Lane
Magnus Hagander writes: > On Wed, Jun 30, 2010 at 19:16, Tom Lane wrote: >> I concur with the thought that the most useful solution might be a way >> to tell pg_restore to remove or disable check constraints. > Uh, say what? Are you saying pg_restore should actually remove > something from the d

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Merlin Moncure
On Wed, Jun 30, 2010 at 9:47 AM, Magnus Hagander wrote: > We currently allow this: > > postgres=# create table t(a timestamptz not null primary key, check(a > > now())); > NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index > "t_pkey" for table "t" > CREATE TABLE > > > Which seems very

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Magnus Hagander
On Wed, Jun 30, 2010 at 19:16, Tom Lane wrote: > Robert Haas writes: >> On Wed, Jun 30, 2010 at 11:49 AM, Tom Lane wrote: >>> I can't recall many >>> field complaints about it.  And the ones I do recall wouldn't have been >>> prevented by a check as stupid as "are there immutable functions in >>

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Magnus Hagander
On Wed, Jun 30, 2010 at 18:33, Richard Huxton wrote: > On 30/06/10 17:11, Robert Haas wrote: >> >> On Wed, Jun 30, 2010 at 11:49 AM, Tom Lane  wrote: >>> >>> Robert Haas  writes: My scintillating contribution to this discussion is the observation that unrestorable dumps suck. >>> >>

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Richard Huxton
On 30/06/10 18:11, Magnus Hagander wrote: On Wed, Jun 30, 2010 at 18:33, Richard Huxton wrote: IMHO The real solution would be something that could strip/rewrite the constraint on restore rather than trying to prevent people being stupid though. People *will* just tag their functions as immuta

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Tom Lane
Robert Haas writes: > On Wed, Jun 30, 2010 at 11:49 AM, Tom Lane wrote: >> I can't recall many >> field complaints about it.  And the ones I do recall wouldn't have been >> prevented by a check as stupid as "are there immutable functions in >> here". > Hopefully there aren't too many ways to get

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Richard Huxton
On 30/06/10 17:11, Robert Haas wrote: On Wed, Jun 30, 2010 at 11:49 AM, Tom Lane wrote: Robert Haas writes: My scintillating contribution to this discussion is the observation that unrestorable dumps suck. No doubt, but is this a real problem in practice? Magnus tells me that that was wha

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Robert Haas
On Wed, Jun 30, 2010 at 11:49 AM, Tom Lane wrote: > Robert Haas writes: >> My scintillating contribution to this discussion is the observation >> that unrestorable dumps suck. > > No doubt, but is this a real problem in practice? Magnus tells me that that was what prompted his original email. >

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Tom Lane
Robert Haas writes: > My scintillating contribution to this discussion is the observation > that unrestorable dumps suck. No doubt, but is this a real problem in practice? I can't recall many field complaints about it. And the ones I do recall wouldn't have been prevented by a check as stupid a

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Robert Haas
On Wed, Jun 30, 2010 at 11:02 AM, Tom Lane wrote: > Magnus Hagander writes: >> On Wed, Jun 30, 2010 at 16:38, Tom Lane wrote: >>> The example seems to me to be in the category of "so don't do that" >>> rather than something that we need to save users from.  Yes, it's > >> In that case, should we

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Tom Lane
Magnus Hagander writes: > On Wed, Jun 30, 2010 at 16:38, Tom Lane wrote: >> The example seems to me to be in the category of "so don't do that" >> rather than something that we need to save users from.  Yes, it's > In that case, should we at least throw a warning? I don't see a reason to do tha

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Magnus Hagander
On Wed, Jun 30, 2010 at 16:38, Tom Lane wrote: > Magnus Hagander writes: >> Shouldn't we disallow anything that's not IMMUTABLE in a check constraint? > > I think you'd get too many howls of pain ... also, such a restriction is > likely contrary to SQL spec. Really? That sounds strange, but I ca

Re: [HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Tom Lane
Magnus Hagander writes: > Shouldn't we disallow anything that's not IMMUTABLE in a check constraint? I think you'd get too many howls of pain ... also, such a restriction is likely contrary to SQL spec. The example seems to me to be in the category of "so don't do that" rather than something tha

[HACKERS] Check constraints on non-immutable keys

2010-06-30 Thread Magnus Hagander
We currently allow this: postgres=# create table t(a timestamptz not null primary key, check(a > now())); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t_pkey" for table "t" CREATE TABLE Which seems very wrong. For one thing, a dump of this database can not be restored if now()