Re: [HACKERS] named generic constraints [feature request]

2009-12-06 Thread Pavel Stehule
2009/12/7 Caleb Cushing : >> no - >> >> "--" is line comment in SQL - it same like "//" in C++ > > sorry didn't see this was updated. I know -- is a comment > > I mean in sql <> means NOT your function name is emptystr which > implies it looks for an emptystr and returns true if the string is > fou

Re: [HACKERS] named generic constraints [feature request]

2009-12-06 Thread Caleb Cushing
> no - > > "--" is line comment in SQL - it same like "//" in C++ sorry didn't see this was updated. I know -- is a comment I mean in sql <> means NOT your function name is emptystr which implies it looks for an emptystr and returns true if the string is found to be empty (at least in my mind). s

Re: [HACKERS] named generic constraints [feature request]

2009-11-23 Thread Pavel Stehule
2009/11/24 Caleb Cushing : >> 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)), > > although I'm not going to continue discussing the request. this c

Re: [HACKERS] named generic constraints [feature request]

2009-11-23 Thread Josh Berkus
Caleb, I can understand why you want this. However, it would be tricky to implement because of data typing, and is fairly easily worked around using either domains or functions. So I don't think anyone is going to want to add it to the TODO list, sorry. Of course, Postgres is fully hackable if

Re: [HACKERS] named generic constraints [feature request]

2009-11-23 Thread Caleb Cushing
> 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)), although I'm not going to continue discussing the request. this code as the opposite desired effect. i

Re: [HACKERS] named generic constraints [feature request]

2009-11-23 Thread Peter Eisentraut
On mån, 2009-11-23 at 12:50 -0500, Caleb Cushing wrote: > and domains > only seem right if it's something, like a zip code, that has a very > specific set of rules, that is in reality it's own type. A domain is not really its own type, it's a domain over its base type. Hence the name. > where > s

Re: [HACKERS] named generic constraints [feature request]

2009-11-23 Thread Pavel Stehule
2009/11/23 Caleb Cushing : > On Mon, Nov 23, 2009 at 4:17 AM, Pavel Stehule > wrote: >> Hello >> >> do you know domains? It is very similar to your proposal. >> > > obviously since I cited it. > >> constraint cannot be  part of  expression. >> > why not? NOT NULL is a contraint, UNIQUE is a conts

Re: [HACKERS] named generic constraints [feature request]

2009-11-23 Thread Caleb Cushing
On Mon, Nov 23, 2009 at 4:17 AM, Pavel Stehule wrote: > Hello > > do you know domains? It is very similar to your proposal. > obviously since I cited it. > constraint cannot be  part of  expression. > why not? NOT NULL is a contraint, UNIQUE is a contstraint. > CREATE OR REPLACE FUNCTION emptys

Re: [HACKERS] named generic constraints [feature request]

2009-11-23 Thread Pavel Stehule
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 : > 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

[HACKERS] named generic constraints [feature request]

2009-11-23 Thread Caleb Cushing
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