Argument casting hierarchy?

From: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Argument casting hierarchy?
Date: 2019-07-01 19:18:33
Message-ID: CAOC+FBVZzMgF5u91E8sFUPht_8s+Xy5PVxWQ1qncgZLCkM4sMQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi guys, hoping you can help clarify what the 'hierarchy' of casts might be
in function arguments.

Meaning I have the following two functions

stats.foo1 (a bigint, b bigint) returns a/b::numeric

stats.foo1 (a real, b real) returns a/b::numeric

It's essentially the same function, but I thought I had to create two to
accept the different types.

However, when I call stats.foo1(3::smallint, 4::smallint) I receive the old:

ERROR: function stats.foo(smallint, smallint) is not unique

Along w/ the message to explicitly cast.

I am essentially trying to write one function that will cast "down", I
guess, anything smaller than what's passed. I am guessing I only need the
real/real argument signature, but I wanted some clarity from the group.

I appreciate it.

--
Wells Oliver
wells(dot)oliver(at)gmail(dot)com <wellsoliver(at)gmail(dot)com>

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ron 2019-07-01 19:30:24 Re: Statistics tables not being updated anymore
Previous Message Adrian Klaver 2019-07-01 18:48:33 Re: Statistics tables not being updated anymore