Re: lexing small ints as int2

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: lexing small ints as int2
Date: 2010-09-04 03:43:31
Message-ID: AANLkTiksn5+-1=w4efm=6zjFs1Ov_MN-h4rLbiQrCua7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 3, 2010 at 9:19 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> The problem I'm facing is functions declared to take type smallint not
> working unless the integer literal has an explicit cast.  Currently the
> best answer is simply to avoid using smallint in functions, but this
> isn't completely satisfying.

Maybe the lexer isn't the right place to fix this. The problem here
(or so I gather) is that if I say foo(1), then 1 is an integer and
we'll do an "implicit" cast to bigint, real, double precision,
numeric, oid, or reg*, but the cast to smallint is assignment-only.
But I wonder if we shouldn't allow implicit casting anyway when there
is a unique best match. If the only foo(x) function is foo(smallint)
and the user tries to call foo with one argument, what else can it
mean?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-09-04 04:26:53 Re: lexing small ints as int2
Previous Message Alvaro Herrera 2010-09-04 01:19:57 Re: lexing small ints as int2