From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: constraint definition on an array column? |
Date: | 2009-09-11 15:51:01 |
Message-ID: | b42b73150909110851m1c4e88e2kced995798ecd3d69@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, Sep 11, 2009 at 10:34 AM, Gauthier, Dave
<dave(dot)gauthier(at)intel(dot)com> wrote:
> Hi:
>
> Is it possible to define a constraint that checks all elements of an array
> type column?
>
> Example...
>
>
>
> create table foo (asset text, owner_uids text[]);
>
>
>
> I also have a plperlu function that checks to see if a given uid is valid
> (returns a 0/1). It’s called validate_uid(text), This function could be
> modified to handle a list of uids if that was needed.
>
>
>
> I want something like...
>
>
>
> constraint validate_all_owner_uids check (select validate_uid(owner_uid) =
> 1)
>
>
>
> ...but owner_uid is an array, not any one distinct value.
>
>
>
> 1) Is there a way to pass in a list for the plperlu to evaluate (return
> 0 if any uid is invalid)?
>
> 2) Is there some sort of syntactical support for defining constraints on
> array columns?
there doesn't have to be. since a constraint can invoke a function
(preferably immutable), you can do anything you want regarding
validating the array.
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | VANOLE, MICHAEL J (ATTSI) | 2009-09-11 16:58:35 | Solaris 9 upgrade to Solaris 10 |
Previous Message | Raymond O'Donnell | 2009-09-11 15:41:47 | Re: return multiple rows |