constraint definition on an array column?

From: "Gauthier, Dave" <dave(dot)gauthier(at)intel(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: constraint definition on an array column?
Date: 2009-09-11 14:34:48
Message-ID: 482E80323A35A54498B8B70FF2B8798004189C01B7@azsmsx504.amr.corp.intel.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Thanks in Advance!

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Kellerer 2009-09-11 14:51:46 Re: Open source database design tool , alternative to MicroOLDAP
Previous Message erik 2009-09-11 12:24:12 8.3.7 server fails to start on Snow Leopard 10.6.1