RE: Time delayed LR (WAS Re: logical replication restrictions) - Mailing list pgsql-hackers

From Hayato Kuroda (Fujitsu)
Subject RE: Time delayed LR (WAS Re: logical replication restrictions)
Date
Msg-id TYAPR01MB5866644C07511D883B50DDAAF5D09@TYAPR01MB5866.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Time delayed LR (WAS Re: logical replication restrictions)  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses Re: Time delayed LR (WAS Re: logical replication restrictions)
List pgsql-hackers
Dear Horiguchi-san,

> I'm not sure. I think that int is generally thought that it is tied
> with an integer type of any size.  min_apply_delay is tightly bond
> with a catalog column of int32 thus I thought that (PG_)INT32_MAX is
> the right limit.  So, as I expressed before, if we assume sizeof(int)
> <= sizeof(int32), I' fine with using INT_MAX there.

I have checked some articles and I think platforms supported by postgres regard
Int as 32-bit integer.


According to the definition of C99, actual value of INT_MAX/INT_MIN depend on the
implementation - INT_MAX must bigger than or equal to 2^15 - 1 [1].
So theoretically there is a possibility that int is bigger than int, as you worried.


Next, I checked some data models, and found ILP64 that regards int as 64-bit integer.
In this case INT_MAX may be 2^63-1, it exceeds PG_INT32_MAX.
I cannot find the proper document about the type, but I can site a table from the doc[2].

```
Datatype    LP64    ILP64    LLP64    ILP32    LP32
char    8    8    8    8    8
short    16    16    16    16    16
_int32        32
int    32    64    32    32    16
long    64    64    32    32    32
long long            64
pointer    64    64    64    32    32
```

I'm not sure whether the system survives or not. According to [2], a few system
released, but I have never heard. Modern systems have LP64 or LLP64.

> There have been a few examples of ILP64 systems that have shipped
> (Cray and ETA come to mind).

In another paper[3], Sun UltraSPARC, which is 32-bit OS and use SPARC64 processor,
seems to use ILP64 model, but it may be ancient OS.

> 1995 Sun UltraSPARC: 64/32-bit hardware, 32-bit-only operating system. HAL Computer’s SPARC64: uses ILP64 model for
C.

Also, I checked buildfarm animals that have Sparc64 architecture,
but their alignment of int seems to be 4 byte [4].

> checking alignment of int... 4

Therefore, I think we can say that modern platforms that are supported by PostgreSQL define int as 32-bit.
It satisfies the condition sizeof(int) <= sizeof(int32), so we can keep to use INT_MAX.

[1] https://www.dii.uchile.cl/~daespino/files/Iso_C_1999_definition.pdf
[2] https://unix.org/version2/whatsnew/lp64_wp.html
[3] https://queue.acm.org/detail.cfm?id=1165766
[4]
https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=castoroides&dt=2023-01-30%2012%3A00%3A07&stg=configure#:~:text=checking%20alignment%20of%20int...%204

Best Regards,
Hayato Kuroda
FUJITSU LIMITED




pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Assertion failure in SnapBuildInitialSnapshot()
Next
From: Peter Eisentraut
Date:
Subject: Re: MacOS: xsltproc fails with "warning: failed to load external entity"