=== Applying patches on top of PostgreSQL commit ID 99139c46cbf2bda7880592c4e5da1ebf177888ac === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Wed Aug 6 15:07:22 UTC 2025 On branch cf/5166 nothing to commit, working tree clean === using 'git am' to apply patch ./v7-0001-Tidy-up-locale-thread-safety-in-ECPG-library.patch === Applying: Tidy up locale thread safety in ECPG library. Using index info to reconstruct a base tree... M configure M configure.ac M meson.build M src/include/pg_config.h.in M src/include/port.h M src/interfaces/ecpg/ecpglib/connect.c M src/interfaces/ecpg/ecpglib/descriptor.c M src/interfaces/ecpg/ecpglib/ecpglib_extern.h M src/interfaces/ecpg/ecpglib/execute.c M src/interfaces/ecpg/pgtypeslib/numeric.c M src/port/Makefile M src/port/meson.build M src/port/snprintf.c Falling back to patching base and 3-way merge... Auto-merging src/port/snprintf.c Auto-merging src/port/meson.build Auto-merging src/port/Makefile Auto-merging src/interfaces/ecpg/pgtypeslib/numeric.c Auto-merging src/interfaces/ecpg/ecpglib/execute.c CONFLICT (content): Merge conflict in src/interfaces/ecpg/ecpglib/execute.c Auto-merging src/interfaces/ecpg/ecpglib/ecpglib_extern.h Auto-merging src/interfaces/ecpg/ecpglib/descriptor.c CONFLICT (content): Merge conflict in src/interfaces/ecpg/ecpglib/descriptor.c Auto-merging src/interfaces/ecpg/ecpglib/connect.c CONFLICT (content): Merge conflict in src/interfaces/ecpg/ecpglib/connect.c Auto-merging src/include/port.h Auto-merging src/include/pg_config.h.in Auto-merging meson.build Auto-merging configure.ac CONFLICT (content): Merge conflict in configure.ac Auto-merging configure CONFLICT (content): Merge conflict in configure error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Tidy up locale thread safety in ECPG library. When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". Unstaged changes after reset: M configure M configure.ac M meson.build M src/include/pg_config.h.in M src/include/port.h M src/include/port/win32_port.h M src/interfaces/ecpg/ecpglib/connect.c M src/interfaces/ecpg/ecpglib/data.c M src/interfaces/ecpg/ecpglib/descriptor.c M src/interfaces/ecpg/ecpglib/ecpglib_extern.h M src/interfaces/ecpg/ecpglib/execute.c M src/interfaces/ecpg/pgtypeslib/dt_common.c M src/interfaces/ecpg/pgtypeslib/interval.c M src/interfaces/ecpg/pgtypeslib/numeric.c M src/port/Makefile M src/port/meson.build M src/port/snprintf.c Removing src/port/locale.c === using patch(1) to apply patch ./v7-0001-Tidy-up-locale-thread-safety-in-ECPG-library.patch === patching file configure Hunk #1 FAILED at 14934. 1 out of 1 hunk FAILED -- saving rejects to file configure.rej patching file configure.ac Hunk #1 FAILED at 1718. 1 out of 1 hunk FAILED -- saving rejects to file configure.ac.rej patching file meson.build Hunk #1 succeeded at 2904 with fuzz 2 (offset 256 lines). patching file src/include/pg_config.h.in Hunk #1 succeeded at 370 (offset 21 lines). Hunk #2 succeeded at 418 (offset 21 lines). patching file src/include/port.h patching file src/include/port/win32_port.h patching file src/interfaces/ecpg/ecpglib/connect.c Hunk #2 succeeded at 208 with fuzz 2 (offset -56 lines). Hunk #3 FAILED at 479. 1 out of 3 hunks FAILED -- saving rejects to file src/interfaces/ecpg/ecpglib/connect.c.rej patching file src/interfaces/ecpg/ecpglib/data.c patching file src/interfaces/ecpg/ecpglib/descriptor.c Hunk #1 FAILED at 475. 1 out of 1 hunk FAILED -- saving rejects to file src/interfaces/ecpg/ecpglib/descriptor.c.rej patching file src/interfaces/ecpg/ecpglib/ecpglib_extern.h patching file src/interfaces/ecpg/ecpglib/execute.c Hunk #2 FAILED at 1970. Hunk #3 succeeded at 2231 (offset 18 lines). 1 out of 3 hunks FAILED -- saving rejects to file src/interfaces/ecpg/ecpglib/execute.c.rej patching file src/interfaces/ecpg/pgtypeslib/dt_common.c patching file src/interfaces/ecpg/pgtypeslib/interval.c patching file src/interfaces/ecpg/pgtypeslib/numeric.c patching file src/port/Makefile patching file src/port/locale.c patching file src/port/meson.build Hunk #1 succeeded at 5 with fuzz 1. patching file src/port/snprintf.c Hunk #2 succeeded at 1247 (offset -3 lines). Hunk #3 succeeded at 1271 (offset -3 lines). Hunk #4 succeeded at 1284 (offset -3 lines). Hunk #5 succeeded at 1411 (offset -3 lines). Unstaged changes after reset: M meson.build M src/include/pg_config.h.in M src/include/port.h M src/include/port/win32_port.h M src/interfaces/ecpg/ecpglib/connect.c M src/interfaces/ecpg/ecpglib/data.c M src/interfaces/ecpg/ecpglib/ecpglib_extern.h M src/interfaces/ecpg/ecpglib/execute.c M src/interfaces/ecpg/pgtypeslib/dt_common.c M src/interfaces/ecpg/pgtypeslib/interval.c M src/interfaces/ecpg/pgtypeslib/numeric.c M src/port/Makefile M src/port/meson.build M src/port/snprintf.c Removing configure.ac.rej Removing configure.rej Removing src/interfaces/ecpg/ecpglib/connect.c.rej Removing src/interfaces/ecpg/ecpglib/descriptor.c.rej Removing src/interfaces/ecpg/ecpglib/execute.c.rej Removing src/port/locale.c === using 'git apply' to apply patch ./v7-0001-Tidy-up-locale-thread-safety-in-ECPG-library.patch === Applied patch to 'configure' with conflicts. Applied patch to 'configure.ac' with conflicts. Applied patch to 'meson.build' cleanly. Applied patch to 'src/include/pg_config.h.in' cleanly. Applied patch to 'src/include/port.h' cleanly. Applied patch to 'src/include/port/win32_port.h' cleanly. Applied patch to 'src/interfaces/ecpg/ecpglib/connect.c' with conflicts. Applied patch to 'src/interfaces/ecpg/ecpglib/data.c' cleanly. Applied patch to 'src/interfaces/ecpg/ecpglib/descriptor.c' with conflicts. Applied patch to 'src/interfaces/ecpg/ecpglib/ecpglib_extern.h' cleanly. Applied patch to 'src/interfaces/ecpg/ecpglib/execute.c' with conflicts. Applied patch to 'src/interfaces/ecpg/pgtypeslib/dt_common.c' cleanly. Applied patch to 'src/interfaces/ecpg/pgtypeslib/interval.c' cleanly. Applied patch to 'src/interfaces/ecpg/pgtypeslib/numeric.c' cleanly. Applied patch to 'src/port/Makefile' cleanly. Falling back to direct application... Applied patch to 'src/port/meson.build' cleanly. Applied patch to 'src/port/snprintf.c' cleanly. U configure U configure.ac U src/interfaces/ecpg/ecpglib/connect.c U src/interfaces/ecpg/ecpglib/descriptor.c U src/interfaces/ecpg/ecpglib/execute.c diff --cc configure index 507a2437c33,017e63598c1..00000000000 --- a/configure +++ b/configure @@@ -15639,7 -14934,7 +15639,11 @@@ f LIBS_including_readline="$LIBS" LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'` ++<<<<<<< ours +for ac_func in backtrace_symbols copyfile copy_file_range elf_aux_info getauxval getifaddrs getpeerucred inet_pton kqueue localeconv_l mbstowcs_l posix_fallocate ppoll pthread_is_threaded_np setproctitle setproctitle_fast strsignal syncfs sync_file_range uselocale wcstombs_l ++======= + for ac_func in backtrace_symbols copyfile copy_file_range elf_aux_info getauxval getifaddrs getpeerucred inet_pton kqueue mbstowcs_l memset_s posix_fallocate ppoll pthread_is_threaded_np setproctitle setproctitle_fast snprintf_l strtod_l strchrnul strsignal syncfs sync_file_range uselocale wcstombs_l ++>>>>>>> theirs do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" diff --cc configure.ac index 5f4548adc5c,b06a9cd1080..00000000000 --- a/configure.ac +++ b/configure.ac @@@ -1804,6 -1718,9 +1804,12 @@@ AC_CHECK_FUNCS(m4_normalize( pthread_is_threaded_np setproctitle setproctitle_fast ++<<<<<<< ours ++======= + snprintf_l + strtod_l + strchrnul ++>>>>>>> theirs strsignal syncfs sync_file_range diff --cc src/interfaces/ecpg/ecpglib/connect.c index 78de9f298ba,475f0215603..00000000000 --- a/src/interfaces/ecpg/ecpglib/connect.c +++ b/src/interfaces/ecpg/ecpglib/connect.c @@@ -274,7 -264,7 +270,11 @@@ ECPGconnect(int lineno, int c, const ch const char **conn_keywords; const char **conn_values; ++<<<<<<< ours + if (alloc_failed) ++======= + if (sqlca == NULL || !pg_ensure_c_locale()) ++>>>>>>> theirs { ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); @@@ -503,40 -479,10 +503,47 @@@ /* add connection to our list */ pthread_mutex_lock(&connections_mutex); ++<<<<<<< ours + /* + * ... but first, make certain we have created ecpg_clocale. Rely on + * holding connections_mutex to ensure this is done by only one thread. + */ +#ifdef HAVE_USELOCALE + if (!ecpg_clocale) + { + ecpg_clocale = newlocale(LC_NUMERIC_MASK, "C", (locale_t) 0); + if (!ecpg_clocale) + { + pthread_mutex_unlock(&connections_mutex); + ecpg_raise(lineno, ECPG_OUT_OF_MEMORY, + ECPG_SQLSTATE_ECPG_OUT_OF_MEMORY, NULL); + if (host) + ecpg_free(host); + if (port) + ecpg_free(port); + if (options) + ecpg_free(options); + if (realname) + ecpg_free(realname); + if (dbname) + ecpg_free(dbname); + if (conn_keywords) + ecpg_free(conn_keywords); + if (conn_values) + ecpg_free(conn_values); + if (this->name) + ecpg_free(this->name); + free(this); + return false; + } + } +#endif ++======= + if (connection_name != NULL) + this->name = ecpg_strdup(connection_name, lineno); + else + this->name = ecpg_strdup(realname, lineno); ++>>>>>>> theirs this->cache_head = NULL; this->prep_stmts = NULL; diff --cc src/interfaces/ecpg/ecpglib/descriptor.c index 466428edfeb,fc5e1c9dd89..00000000000 --- a/src/interfaces/ecpg/ecpglib/descriptor.c +++ b/src/interfaces/ecpg/ecpglib/descriptor.c @@@ -476,35 -475,6 +476,38 @@@ ECPGget_desc(int lineno, const char *de memset(&stmt, 0, sizeof stmt); stmt.lineno = lineno; ++<<<<<<< ours + /* Make sure we do NOT honor the locale for numeric input */ + /* since the database gives the standard decimal point */ + /* (see comments in execute.c) */ +#ifdef HAVE_USELOCALE + + /* + * To get here, the above PQnfields() test must have found nonzero + * fields. One needs a connection to create such a descriptor. (EXEC + * SQL SET DESCRIPTOR can populate the descriptor's "items", but it + * can't change the descriptor's PQnfields().) Any successful + * connection initializes ecpg_clocale. + */ + Assert(ecpg_clocale); + stmt.oldlocale = uselocale(ecpg_clocale); +#else +#ifdef WIN32 + stmt.oldthreadlocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); +#endif + stmt.oldlocale = ecpg_strdup(setlocale(LC_NUMERIC, NULL), + lineno, &alloc_failed); + if (alloc_failed) + { + va_end(args); + return false; + } + + setlocale(LC_NUMERIC, "C"); +#endif + ++======= ++>>>>>>> theirs /* desperate try to guess something sensible */ stmt.connection = ecpg_get_connection(NULL); ecpg_store_result(ECPGresult, index, &stmt, &data_var); diff --cc src/interfaces/ecpg/ecpglib/execute.c index 84a4a9fc578,ec939d0f63a..00000000000 --- a/src/interfaces/ecpg/ecpglib/execute.c +++ b/src/interfaces/ecpg/ecpglib/execute.c @@@ -1974,44 -1971,6 +1971,47 @@@ ecpg_do_prologue(int lineno, const int return false; /* ++<<<<<<< ours + * Make sure we do NOT honor the locale for numeric input/output since the + * database wants the standard decimal point. If available, use + * uselocale() for this because it's thread-safe. Windows doesn't have + * that, but it does have _configthreadlocale(). + */ +#ifdef HAVE_USELOCALE + + /* + * Since ecpg_init() succeeded, we have a connection. Any successful + * connection initializes ecpg_clocale. + */ + Assert(ecpg_clocale); + stmt->oldlocale = uselocale(ecpg_clocale); + if (stmt->oldlocale == (locale_t) 0) + { + ecpg_do_epilogue(stmt); + return false; + } +#else +#ifdef WIN32 + stmt->oldthreadlocale = _configthreadlocale(_ENABLE_PER_THREAD_LOCALE); + if (stmt->oldthreadlocale == -1) + { + ecpg_do_epilogue(stmt); + return false; + } +#endif + stmt->oldlocale = ecpg_strdup(setlocale(LC_NUMERIC, NULL), lineno, + NULL); + if (stmt->oldlocale == NULL) + { + ecpg_do_epilogue(stmt); + return false; + } + setlocale(LC_NUMERIC, "C"); +#endif + + /* ++======= ++>>>>>>> theirs * If statement type is ECPGst_prepnormal we are supposed to prepare the * statement before executing them */