pgsql: ecpglib: call newlocale() once per process.

Поиск
Список
Период
Сортировка
От Noah Misch
Тема pgsql: ecpglib: call newlocale() once per process.
Дата
Msg-id E1o7jJk-000sy0-3i@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
ecpglib: call newlocale() once per process.

ecpglib has been calling it once per SQL query and once per EXEC SQL GET
DESCRIPTOR.  Instead, if newlocale() has not succeeded before, call it
while establishing a connection.  This mitigates three problems:
- If newlocale() failed in EXEC SQL GET DESCRIPTOR, the command silently
  proceeded without the intended locale change.
- On AIX, each newlocale()+freelocale() cycle leaked memory.
- newlocale() CPU usage may have been nontrivial.

Fail the connection attempt if newlocale() fails.  Rearrange
ecpg_do_prologue() to validate the connection before its uselocale().

The sort of program that may regress is one running in an environment
where newlocale() fails.  If that program establishes connections
without running SQL statements, it will stop working in response to this
change.  I'm betting against the importance of such an ECPG use case.
Most SQL execution (any using ECPGdo()) has long required newlocale()
success, so there's little a connection could do without newlocale().

Back-patch to v10 (all supported versions).

Reviewed by Tom Lane.  Reported by Guillaume Lelarge.

Discussion: https://postgr.es/m/20220101074055.GA54621@rfd.leadboat.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b4d7e92bd5354c78c0d0405d08d85b73d20f50f7

Modified Files
--------------
src/interfaces/ecpg/ecpglib/connect.c        | 40 ++++++++++++++++++++++++++++
src/interfaces/ecpg/ecpglib/descriptor.c     | 15 +++++++----
src/interfaces/ecpg/ecpglib/ecpglib_extern.h |  5 +++-
src/interfaces/ecpg/ecpglib/execute.c        | 40 ++++++++++++----------------
4 files changed, 71 insertions(+), 29 deletions(-)


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

Предыдущее
От: Jeff Davis
Дата:
Сообщение: pgsql: Emit debug message when executing extension script.
Следующее
От: Noah Misch
Дата:
Сообщение: pgsql: Fix previous commit's ecpg_clocale for ppc Darwin.