Re: Question about integer out of range in function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Condor <condor(at)stz-bg(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Question about integer out of range in function
Date: 2021-05-14 14:42:23
Message-ID: 1883415.1621003343@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Condor <condor(at)stz-bg(dot)com> writes:
> new_time = fromtime * 1000; -- here is line 19

Are you entirely certain that you counted lines correctly?
If new_time and fromtime are both declared bigint, and
fromtime is on the order of

# select extract(epoch from now())::bigint;
extract
------------
1621003124
(1 row)

then there's no way that that statement fails on integer overflow.

What I'm wondering about is the next line:

> unix_time = (new_time + rand_int)::BIGINT;

You've not shown us the declaration of unix_time ...

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2021-05-14 14:49:48 Re: Same column names in a subresult table
Previous Message Bharath Rupireddy 2021-05-14 12:10:33 Re: Query on postgres_fdw extension