Re: "long" type is not appropriate for counting tuples

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Peter Geoghegan <pg(at)bowt(dot)ie>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: "long" type is not appropriate for counting tuples
Date: 2019-06-06 12:58:09
Message-ID: CA+TgmobQrhsHFCkCH4kZsEsdXhb+x52xy3Q8HKnsq2QpUcZbUw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, May 23, 2019 at 10:21 AM Peter Eisentraut
<peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
> Hmm, by that argument, we shouldn't ever use any integer type other than
> int16, int32, and int64.

I think we basically shouldn't. I mean it's fine to use 'int' as a
flags argument as part of an internal API, or as a loop counter
private to a function or something. But if you are passing around
values that involve on-disk compatibility or wire protocol
compatibility, it's just a recipe for bugs. If the code has to
sometimes cast a value to some other type, somebody may do it wrong.
If there's a uniform rule that tuple counts are always int64, that's
pretty easy to understand.

In short, when a certain kind of value is widely-used, it should have
a clearly-declared width.

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-06-06 13:11:58 Re: pg_checksums has an untranslatable string.
Previous Message Peter Eisentraut 2019-06-06 12:50:49 Re: "long" type is not appropriate for counting tuples