RE: Time delayed LR (WAS Re: logical replication restrictions)

From: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
To: 'Kyotaro Horiguchi' <horikyota(dot)ntt(at)gmail(dot)com>, "amit(dot)kapila16(at)gmail(dot)com" <amit(dot)kapila16(at)gmail(dot)com>
Cc: "Takamichi Osumi (Fujitsu)" <osumi(dot)takamichi(at)fujitsu(dot)com>, "smithpb2250(at)gmail(dot)com" <smithpb2250(at)gmail(dot)com>, "vignesh21(at)gmail(dot)com" <vignesh21(at)gmail(dot)com>, "shveta(dot)malik(at)gmail(dot)com" <shveta(dot)malik(at)gmail(dot)com>, "dilipbalaut(at)gmail(dot)com" <dilipbalaut(at)gmail(dot)com>, "euler(at)eulerto(dot)com" <euler(at)eulerto(dot)com>, "m(dot)melihmutlu(at)gmail(dot)com" <m(dot)melihmutlu(at)gmail(dot)com>, "andres(at)anarazel(dot)de" <andres(at)anarazel(dot)de>, "marcos(at)f10(dot)com(dot)br" <marcos(at)f10(dot)com(dot)br>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Time delayed LR (WAS Re: logical replication restrictions)
Date: 2023-01-31 07:06:40
Message-ID: TYAPR01MB5866644C07511D883B50DDAAF5D09@TYAPR01MB5866.jpnprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2023-01-31 07:43:56 Re: MacOS: xsltproc fails with "warning: failed to load external entity"
Previous Message Masahiko Sawada 2023-01-31 06:59:38 Re: Assertion failure in SnapBuildInitialSnapshot()