diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c
index bbf100e..560a324 100644
*** a/src/backend/utils/adt/pg_locale.c
--- b/src/backend/utils/adt/pg_locale.c
*************** PGLC_localeconv(void)
*** 562,567 ****
--- 562,574 ----
  	setlocale(LC_CTYPE, locale_numeric);
  #endif
  
+         /*
+          * Ensure the global locale is being used. This is
+          * necessary, for example, if another loaded library
+          * such as libperl has done uselocale() underneath us.
+          * */
+         uselocale(LC_GLOBAL_LOCALE);
+ 
  	/* Get formatting information for numeric */
  	setlocale(LC_NUMERIC, locale_numeric);
  	extlconv = localeconv();
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index e7f31f2..03d6623 100644
*** a/src/fe_utils/print.c
--- b/src/fe_utils/print.c
*************** setDecimalLocale(void)
*** 3402,3407 ****
--- 3402,3413 ----
  {
  	struct lconv *extlconv;
  
+         /*
+          * Ensure the global locale is being used. This is
+          * necessary, for example, if another loaded library
+          * such as libperl has done uselocale() underneath us.
+          * */
+         uselocale(LC_GLOBAL_LOCALE);
  	extlconv = localeconv();
  
  	/* Don't accept an empty decimal_point string */
