Do not try to change a const variable.
authorMichael Meskes <meskes@postgresql.org>
Mon, 15 Dec 2008 15:34:07 +0000 (15:34 +0000)
committerMichael Meskes <meskes@postgresql.org>
Mon, 15 Dec 2008 15:34:07 +0000 (15:34 +0000)
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ecpglib/misc.c

index c6064cd0afb4103779033ec17c8a69b8f4afd2c5..89e6490d0f7990dedc005e4e2b38293176f1c64d 100644 (file)
@@ -2396,6 +2396,10 @@ Wed, 26 Nov 2008 14:09:08 +0100
    - When creating a varchar struct name braces must be discarded.
    - Applied patch by Ron Mayer <rm_pg@cheapcomplexdevices.com> to merge
      the new interval style into ecpg.
+
+Mon, 15 Dec 2008 16:31:31 +0100
+
+   - Do not try to change a const variable in ecpg_log.
    - Set pgtypes library version to 3.1.
    - Set compat library version to 3.1.
    - Set ecpg library version to 6.2.
index 29c391612e265d4ddc62f6972be8165ab16bc126..3125a9065c89bcc7f44935f8f6fce424f292a090 100644 (file)
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.44 2008/12/11 07:34:09 petere Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.45 2008/12/15 15:34:07 meskes Exp $ */
 
 #define POSTGRES_ECPG_INTERNAL
 #include "postgres_fe.h"
@@ -241,49 +241,46 @@ void
 ecpg_log(const char *format,...)
 {
    va_list     ap;
-   struct sqlca_t *sqlca = ECPGget_sqlca();
-
-   /* internationalize the error message string */
-   format = ecpg_gettext(format);
-
-   if (simple_debug)
-   {
-       int         bufsize = strlen(format) + 100;
-       char       *f = (char *) malloc(bufsize);
+   struct sqlca_t  *sqlca = ECPGget_sqlca();
+   int     bufsize = strlen(format) + 100;
+   char        *f = (char *) malloc(bufsize),
+           *intl_format;
 
-       if (f == NULL)
-           return;
+   if (!simple_debug || f == NULL)
+       return;
 
-       /*
-        * regression tests set this environment variable to get the same
-        * output for every run.
-        */
-       if (ecpg_internal_regression_mode)
-           snprintf(f, bufsize, "[NO_PID]: %s", format);
-       else
-           snprintf(f, bufsize, "[%d]: %s", (int) getpid(), format);
+   /* internationalize the error message string */
+   intl_format = ecpg_gettext(format);
+
+   /*
+    * regression tests set this environment variable to get the same
+    * output for every run.
+    */
+   if (ecpg_internal_regression_mode)
+       snprintf(f, bufsize, "[NO_PID]: %s", intl_format);
+   else
+       snprintf(f, bufsize, "[%d]: %s", (int) getpid(), intl_format);
 
 #ifdef ENABLE_THREAD_SAFETY
-       pthread_mutex_lock(&debug_mutex);
+   pthread_mutex_lock(&debug_mutex);
 #endif
 
-       va_start(ap, format);
-       vfprintf(debugstream, f, ap);
-       va_end(ap);
+   va_start(ap, format);
+   vfprintf(debugstream, f, ap);
+   va_end(ap);
 
-       /* dump out internal sqlca variables */
-       if (ecpg_internal_regression_mode)
-           fprintf(debugstream, "[NO_PID]: sqlca: code: %ld, state: %s\n",
-                   sqlca->sqlcode, sqlca->sqlstate);
+   /* dump out internal sqlca variables */
+   if (ecpg_internal_regression_mode)
+       fprintf(debugstream, "[NO_PID]: sqlca: code: %ld, state: %s\n",
+               sqlca->sqlcode, sqlca->sqlstate);
 
-       fflush(debugstream);
+   fflush(debugstream);
 
 #ifdef ENABLE_THREAD_SAFETY
-       pthread_mutex_unlock(&debug_mutex);
+   pthread_mutex_unlock(&debug_mutex);
 #endif
 
-       free(f);
-   }
+   free(f);
 }
 
 void