v3-0001-ecpg-Refactor-ecpg_log-to-skip-unnecessary-calls-.patch
text/plain
Filename: v3-0001-ecpg-Refactor-ecpg_log-to-skip-unnecessary-calls-.patch
Type: text/plain
Part: 0
Patch
Format: format-patch
Series: patch v3-0001
Subject: ecpg: Refactor ecpg_log() to skip unnecessary calls to ECPGget_sqlca().
| File | + | − |
|---|---|---|
| src/interfaces/ecpg/ecpglib/misc.c | 3 | 1 |
From 5a0ea1d78cb14ad90d64deb8a521d5627854d850 Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Fri, 18 Oct 2024 14:22:17 +0900
Subject: [PATCH v3] ecpg: Refactor ecpg_log() to skip unnecessary calls to
ECPGget_sqlca().
Previously, ecpg_log() always called ECPGget_sqlca() to retrieve sqlca,
even though it was only needed for debug logging. This commit updates
ecpg_log() to call ECPGget_sqlca() only when debug logging is enabled.
Author: Yuto Sasaki
Reviewed-by: Tom Lane, Fujii Masao
Discussion: https://postgr.es/m/TY2PR01MB3628A85689649BABC9A1C6C3C1782@TY2PR01MB3628.jpnprd01.prod.outlook.com
---
src/interfaces/ecpg/ecpglib/misc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c
index 2ae989e3e5..8b38c3eccf 100644
--- a/src/interfaces/ecpg/ecpglib/misc.c
+++ b/src/interfaces/ecpg/ecpglib/misc.c
@@ -232,10 +232,10 @@ void
ecpg_log(const char *format,...)
{
va_list ap;
- struct sqlca_t *sqlca = ECPGget_sqlca();
const char *intl_format;
int bufsize;
char *fmt;
+ struct sqlca_t *sqlca;
/*
* For performance reasons, inspect simple_debug without taking the mutex.
@@ -262,6 +262,8 @@ ecpg_log(const char *format,...)
else
snprintf(fmt, bufsize, "[%d]: %s", (int) getpid(), intl_format);
+ sqlca = ECPGget_sqlca();
+
pthread_mutex_lock(&debug_mutex);
/* Now that we hold the mutex, recheck simple_debug */
--
2.46.2