Re: Maybe we can remove the type cast in typecache.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: qinghao huang <wfnuser(at)hotmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Maybe we can remove the type cast in typecache.c
Date: 2023-02-28 15:35:39
Message-ID: 746093.1677598539@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

qinghao huang <wfnuser(at)hotmail(dot)com> writes:
> When I was reading postgres code, I found there is a wierd type cast. I'm pondering if it is necessary.

> ```
> /* Allocate a new typmod number. This will be wasted if we error out. */
> typmod = (int)
> pg_atomic_fetch_add_u32(&CurrentSession->shared_typmod_registry->next_typmod,
> 1);

> ```
> typmod has u32 type, but we cast it to int first.

typmods really ought to be int32, not uint32, so IMO none of this is
exactly right. But it's also true that it makes no real difference.
Postgres pretty much assumes that "int" is 32 bits.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Hayato Kuroda (Fujitsu) 2023-02-28 15:51:32 RE: Time delayed LR (WAS Re: logical replication restrictions)
Previous Message Bharath Rupireddy 2023-02-28 15:30:00 Avoid multiple SetLatch() calls in procsignal_sigusr1_handler()