Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Hackers > Re: Resolving p...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 9 Topic 9618 of 11009
Post > Topic >>

Re: Resolving polymorphic functions with related datatypes

by heikki@[EMAIL PROTECTED] ("Heikki Linnakangas") Jul 3, 2008 at 02:11 PM

Simon Riggs wrote:
> I'm using the nvl() function from the orafce package. It is defined as a
> polymorphic function so its function signature is 
>   nvl(anyelement, anyelement)
> 
> Now if I try to use the function in this very typical way
>   nvl(numeric_col, 0)
> 
> we get
> 
>  ERROR: function nvl(numeric, integer) does not exist
> 
> The same error occurs if we have nvl(smallint, integer) etc
> 
> This is a real shame 'cos polymorphic functions ought to be a great way
> of saving development time and catalog space, yet they seem to fall down
> a hole without implicit casting.
> 
> What I'd like it to do is to recognise that the 0 should be cast
> implicitly to another datatype within the same family. I want and expect
>  nvl(char_column, 0)
> to fail, but I expect the various numeric/integer types we have to play
> nicely together without tears.

So, it would be analogous to the 'unknown' type, but for numeric 
literals instead of text literals. Seems reasonable. It still wouldn't 
allow nvl(1::bigint, 2::int4), though, just as the unknown type doesn't 
help with nvl('foo'::text, 'bar'::varchar).

> If we can do it for indexes, can we do it for polymorphic functions also
> when there is no matching function?

Umm, what do indexes have to do with this?
-- 
   Heikki Lin****angas
   EnterpriseDB   http://www.enterprisedb.com

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
 




 9 Posts in Topic:
Resolving polymorphic functions with related datatypes
simon@[EMAIL PROTECTED]   2008-07-03 10:36:09 
Re: Resolving polymorphic functions with related datatypes
pavel.stehule@[EMAIL PROT  2008-07-03 12:22:21 
Re: Resolving polymorphic functions with related
simon@[EMAIL PROTECTED]   2008-07-03 11:51:38 
Re: Resolving polymorphic functions with related datatypes
heikki@[EMAIL PROTECTED]   2008-07-03 14:11:34 
Re: Resolving polymorphic functions with related
simon@[EMAIL PROTECTED]   2008-07-03 13:34:05 
Re: Resolving polymorphic functions with relateddatatypes
stark@[EMAIL PROTECTED]   2008-07-03 13:54:29 
Re: Resolving polymorphic functions with relateddatatypes
tgl@[EMAIL PROTECTED] (T  2008-07-03 12:01:25 
Re: Resolving polymorphic functions with relateddatatypes
simon@[EMAIL PROTECTED]   2008-07-03 14:24:06 
Re: Resolving polymorphic functions with relateddatatypes
pavel.stehule@[EMAIL PROT  2008-07-03 19:42:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Dec 5 8:43:24 CST 2008.