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
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers 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.

Responses

Browse pgsql-hackers by date

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

Browse pgsql-interfaces by date

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