Re: Should we represent temp files as unsigned long int instead of signed long int type?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Should we represent temp files as unsigned long int instead of signed long int type?
Date: 2023-10-25 19:07:39
Message-ID: 1013454.1698260859@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com> writes:
> At present, we represent temp files as a signed long int number. And
> depending on the system architecture (32 bit or 64 bit), the range of
> signed long int varies, for example on a 32-bit system it will range
> from -2,147,483,648 to 2,147,483,647. AFAIU, this will not allow a
> session to create more than 2 billion temporary files and that is not
> a small number at all, but still what if we make it an unsigned long
> int which will allow a session to create 4 billion temporary files if
> needed.

AFAIK, nothing particularly awful will happen if that counter wraps
around. Perhaps if you gamed the system really hard, you could cause
a collision with a still-extant temp file from the previous cycle,
but I seriously doubt that could happen by accident. So I don't
think there's anything to worry about here. Maybe we could make
that filename pattern %lu not %ld, but minus sign is a perfectly
acceptable filename character, so such a change would be cosmetic.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-10-25 19:10:26 Re: Should we represent temp files as unsigned long int instead of signed long int type?
Previous Message Jeff Davis 2023-10-25 19:02:40 Re: Custom tstzrange with importance factored in