From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Caleb Cushing <xenoterracide(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: named generic constraints [feature request] |
Date: | 2009-11-23 09:17:29 |
Message-ID: | 162867790911230117r1082204fned682041ceca1904@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello
do you know domains? It is very similar to your proposal.
http://www.postgresql.org/docs/8.2/static/sql-createdomain.html
Regards
Pavel Stehule
2009/11/23 Caleb Cushing <xenoterracide(at)gmail(dot)com>:
> So last time I checked this wasn't possible (at least not that anyone
> has told me). I'd like to be able to create constraints that aren't
> tied to a specific table/column.
>
> I think that the syntax would look something like this
>
> CREATE CONSTRAINT empty CHECK (VALUE = '\0' );
>
> this should allow us to do thinks like
>
> CREATE TABLE users (
> username TEXT NOT empty
> );
>
constraint cannot be part of expression.
CREATE OR REPLACE FUNCTION emptystr(text)
RETURNS bool AS $$
SELECT $1 <> ''; -- it is SQL not C
$$ LANGUAGE sql;
CREATE TABLE users(
username TEXT CHECK (NOT emptystr(username)),
...
p.s. Is it related to ANSI SQL?
Regards
Pavel Stehule
> the example from create domain (modified) is also pretty good
>
> CREATE CONSTRAINT zip CHECK(
> VALUE ~ '^\\d{5}$'
> OR VALUE ~ '^\\d{5}-\\d{4}$'
> );
>
> --
> Caleb Cushing
>
> http://xenoterracide.blogspot.com
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
From | Date | Subject | |
---|---|---|---|
Next Message | Thom Brown | 2009-11-23 09:18:20 | Re: [HACKERS] Updating column on row update |
Previous Message | Caleb Cushing | 2009-11-23 08:59:29 | named generic constraints [feature request] |