By Passed Domain Constraints - Mailing list pgsql-interfaces

From Robert Perry
Subject By Passed Domain Constraints
Date
Msg-id 61C4410A-F2CE-49E9-92BA-1BDF89818DAA@lodestonetechnologies.com
Whole thread Raw
Responses Re: By Passed Domain Constraints
List pgsql-interfaces
     I have a database in which I used domains with check constraints  
to keep all the constraints nice and uniform for like columns across  
tables.  My users access and update data primarily through function  
calls that have parameters that of DOMAIN types.
    These constraints work when I call the functions via psql or  
from a PHP client.  But, my pqlib users seem to be able to get bad  
data in.  I have not done any real testing yet to track this down,  
but have looks through the archives and have not been able to spot  
anything.  Anybody else seen something like this?  Am I missing  
something fundamental.
    I have noticed that I can cast the bad data to the domain type,  
but not to a varchar and then the domain type.

i.e.

Select passcode::D_PASSCODE from  
employee_passcode;                      -- will work
Select passcode::varchar::D_PASSCODE from employee_passcode;      --  
properly complains --> ERROR:  value for domain d_passcode violates  
check constraint "d_passcode_check"

    It looks like the data is not checked when passed to the  
function and from their on out since it is already the correct type  
it is not checked again. Has anyone else seen something like this?
    I am using 8.0.1.  On the pqlib side we are calling PQexecParams  
and using NULL for param types for the function calls in question.



pgsql-interfaces by date:

Previous
From: jtv@xs4all.nl
Date:
Subject: Re: libpq and connection failures
Next
From: Tom Lane
Date:
Subject: Re: By Passed Domain Constraints