Skip site navigation (1) Skip section navigation (2)

By Passed Domain Constraints

From: Robert Perry <rlperry(at)lodestonetechnologies(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: By Passed Domain Constraints
Date: 2005-07-06 13:49:27
Message-ID: 61C4410A-F2CE-49E9-92BA-1BDF89818DAA@lodestonetechnologies.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-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.


Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2005-07-06 14:26:58
Subject: Re: timezone changes break windows and cygwin
Previous:From: Marko KreenDate: 2005-07-06 10:42:49
Subject: Re: pgcrypto 3des failure, OpenSSL 0.9.8, Solaris 9/sparc

pgsql-interfaces by date

Next:From: Tom LaneDate: 2005-07-06 14:35:37
Subject: Re: By Passed Domain Constraints
Previous:From: jtvDate: 2005-07-06 07:39:12
Subject: Re: libpq and connection failures

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group