Re: [PATCH] Add error message for out-of-memory in passwordFromFile()

Поиск
Список
Период
Сортировка
От Joshua Shanks
Тема Re: [PATCH] Add error message for out-of-memory in passwordFromFile()
Дата
Msg-id CAOxqWDcnHgM3AEYhDjDounf56WXRhaQuuzJBYgfMyfQGH=jTXw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [PATCH] Add error message for out-of-memory in passwordFromFile()  (Michael Paquier <michael@paquier.xyz>)
Ответы Re: [PATCH] Add error message for out-of-memory in passwordFromFile()
Список pgsql-hackers
On Mon, Nov 3, 2025 at 2:35 AM Michael Paquier <michael@paquier.xyz> wrote:
The point would be to have pqConnectOptions2() take its oom_error path
in the case you are pointing at.  It seems to me that the correct
answer would be to extend passwordFromFile() with an extra "const char
**errmsg", where an error is saved, assign an error string in the
routine, check if the error pointer is set when exiting
passwordFromFile() in pqConnectOptions2(), and consume the error
properly before failing in pqConnectOptions2() with a CONNECTION_BAD.

Thank you for the detailed feedback! This is my first C project contribution, so I really appreciate you taking the time to explain the proper error handling pattern.

I've updated the patch to address your concerns:

Changes in v2:
- Extended passwordFromFile() with const char **errmsg parameter to signal actual errors
- Set *errmsg = "out of memory" for OOM cases (enlargePQExpBuffer and strdup failures)
- Updated pqConnectOptions2() to check errmsg and fail with CONNECTION_BAD when set
- Removed the PGconn *conn parameter since error reporting is now handled by the caller
- Updated function comment to document the error signaling convention

Cheers,
Joshua
Вложения

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