RE: [EXTERNAL] Support load balancing in libpq

Поиск
Список
Период
Сортировка
От Hayato Kuroda (Fujitsu)
Тема RE: [EXTERNAL] Support load balancing in libpq
Дата
Msg-id TYAPR01MB58665250EDCD551CCA9AD117F58E9@TYAPR01MB5866.jpnprd01.prod.outlook.com
обсуждение исходный текст
Ответ на Re: [EXTERNAL] Support load balancing in libpq  (Daniel Gustafsson <daniel@yesql.se>)
Ответы Re: [EXTERNAL] Support load balancing in libpq  (Daniel Gustafsson <daniel@yesql.se>)
Список pgsql-hackers
Dear Daniel, Jelte

Thank you for creating a good feature!
While checking the buildfarm, I found a failure on NetBSD caused by the added code[1]:

```
fe-connect.c: In function 'libpq_prng_init':
fe-connect.c:1048:11: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
 1048 |  rseed = ((uint64) conn) ^
      |           ^
cc1: all warnings being treated as errors
```

This failure seemed to occurr when the pointer is casted to different size.
And while checking more, I found that this machine seemed that size of pointer is 4 byte [2],
whereas sizeof(uint64) is 8.

```
checking size of void *... (cached) 4
```

I could not test because I do not have NetBSD, but I have come up with
Following solution to avoid the failure. sizeof(uintptr_t) will be addressed
based on the environment. How do you think?

```
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index a13ec16b32..bb7347cb0c 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -1045,7 +1045,7 @@ libpq_prng_init(PGconn *conn)

        gettimeofday(&tval, NULL);

-       rseed = ((uint64) conn) ^
+       rseed = ((uintptr_t) conn) ^
                        ((uint64) getpid()) ^
                        ((uint64) tval.tv_usec) ^
                        ((uint64) tval.tv_sec);
```

[1]: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=mamba&dt=2023-03-29%2023%3A24%3A44
[2]: https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=mamba&dt=2023-03-29%2023%3A24%3A44&stg=configure

Best Regards,
Hayato Kuroda
FUJITSU LIMITED




В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Kumar, Sachin"
Дата:
Сообщение: RE: Initial Schema Sync for Logical Replication
Следующее
От: "Hayato Kuroda (Fujitsu)"
Дата:
Сообщение: PGdoc: add ID attribute to create_publication.sgml