Search Postgresql Archives

Re: 5 is not a smallint but '5' is

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 29, 2013 at 8:11 AM, John DeSoi <desoi@xxxxxxxxxx> wrote:
I was surprised to discover this today. I can work around it, but it seems counterintuitive. If 5 can't be parsed as a smallint, I would feel better if '5' was not one either.


temp=# create or replace function itest (param smallint) returns integer as $$ select $1 + 5; $$ language sql;
CREATE FUNCTION
temp=# select itest(5);
ERROR:  function itest(integer) does not exist
LINE 1: select itest(5);
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
temp=# select itest('5');
 itest
-------
    10
(1 row)



FWIW, It works if you don't rely on the implicit cast, and explicitly cast it to smallint:

select itest(5::smallint);
 itest
-------
    10

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux