Re: lexing small ints as int2

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: lexing small ints as int2
Date: 2010-09-04 01:19:57
Message-ID: 1283562627-sup-4431@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Excerpts from Tom Lane's message of vie sep 03 19:36:06 -0400 2010:

> > Does anyone know where to find the discussion refered to here?
> > http://archives.postgresql.org/pgsql-hackers/2008-10/msg01485.php
>
> I think this was the last time I tried it:
> http://archives.postgresql.org/pgsql-hackers/2002-11/msg00468.php

Interesting, thanks. I also had some vague thought about conversion
distance today, thinking it could help solve the problem.

> At the time, the main motivation for worrying about it was that cases
> like "WHERE smallintcol = 42" couldn't be indexed, because 42 is int4
> not int2. We've since fixed that by allowing cross-type operators
> to be indexable.

Yeah, that's no longer an issue fortunately.

> I also notice that one of the failure cases I cited might no longer be
> an issue now that we don't have implicit casts to text, but that change
> isn't going to do anything for the other cases.

Right.

> On the whole I'm still afraid that changing the initial typing of
> integer constants is going to break a lot of code while buying not much.
> Do you have a specific reason for reopening the issue? Or is your
> concern something different?

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.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-09-04 03:43:31 Re: lexing small ints as int2
Previous Message Robert Haas 2010-09-04 01:19:06 Re: Interruptible sleeps (was Re: CommitFest 2009-07: Yay, Kevin! Thanks, reviewers!)