Check constraint - Mailing list pgsql-general

From Anand Surelia
Subject Check constraint
Date
Msg-id 35FF04EF.4A5FE4CA@bytekinc.com
Whole thread Raw
List pgsql-general
Hi,
I have created a function "int fname(void)" in C. When I create this
function in Postgres as returning int4 and then do a
" create table dummy (level int4 check(fname() > 4));"
the creation fails saying that :
ERROR:  There is no operator '>' for types 'bool' and 'int4'
        You will either have to retype this query using an explicit
cast,
        or you will have to define the operator using CREATE OPERATOR

I've tried this for different operators and it comes up with the same
error even though I know the operators exist.

However, when I create fname as returning int2 and then create the
table, it says:
NOTICE:  PortalHeapMemoryFree: 0x8178389 not in alloc set!
CREATE

Which means that the table has been created.
Now when I do a insert into the table it fails saying:
PQexec() -- Request was sent to backend, but backend closed the channel
before r
esponding.
        This probably means the backend terminated abnormally before or
while pr
ocessing the request.

Could someone please explain what is going on?

Do the Check constraints do not take functions?

Thanks,
Anand



pgsql-general by date:

Previous
From: Howie
Date:
Subject: subscribe pgsql-general
Next
From: casinogame@iname.com
Date:
Subject: This message is time sensitive.