![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
I sent this a while ago to general and then hackers and got no response. The question is whether to qualify the return value of a function when it returns a domain with a check clause. I believe it should--otherwise the domain is only useful on insert and is not acting like a full fledged type. However, I suspect that there is no underlying support for type checks in the general system. Elein ----- Forwarded message from elein <elein (AT) varlena (DOT) com> ----- I can create a function with a domain and define it to return a domain. The parameter is checked to see if it qualifies in the constraint of the domain, however, the return value is not. Is this a bug? Is the author of the function responsible for re-inforcing the constraint at runtime? This is the test case in 7.4: =# create domain one2hundred AS integer -# DEFAULT '1' CONSTRAINT email_domain check( VALUE > 0 AND VALUE <=100 ); CREATE DOMAIN =# =# create function gb52_add( one2hundred ) -# returns one2hundred as -# ' '# BEGIN '# RETURN $1 + 10; '# END; '# ' language 'plpgsql'; CREATE FUNCTION =# =# select gb52_add( 80); gb52_add ---------- 90 (1 row) =# select gb52_add( 100); gb52_add ---------- 110 (1 row) =# select gb52_add( 90); gb52_add ---------- 100 (1 row) =# select gb52_add( 91); gb52_add ---------- 101 (1 row) =# select gb52_add( 191); ERROR: value for domain one2hundred violates check constraint "email_domain" |
#2
| |||
| |||
|
|
so ISTM that your example is certainly a deficiency if not a bug. |
#3
| |||
| |||
|
|
Shouldn't all function calls go (through fast path or fmgr or the language manager?) to a centralized parameter marshalling? |
#4
| |||
| |||
|
|
Robert Treat <xzilla (AT) users (DOT) sourceforge.net> writes: so ISTM that your example is certainly a deficiency if not a bug. I believe it is a bug or at least an unimplemented feature in plpgsql: plpgsql has its own implementation of casting, and is not aware that casting to a domain should involve running check constraints. The same might be true of the other PL languages, not sure. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org) |
#5
| |||
| |||
|
|
elein <elein (AT) varlena (DOT) com> writes: Shouldn't all function calls go (through fast path or fmgr or the language manager?) to a centralized parameter marshalling? We're talking about what happens inside the function, not how you pass parameters to it. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org) |
![]() |
| Thread Tools | |
| Display Modes | |
| |