diff options
author | Michael Meskes <meskes@postgresql.org> | 2008-12-15 15:34:07 +0000 |
---|---|---|
committer | Michael Meskes <meskes@postgresql.org> | 2008-12-15 15:34:07 +0000 |
commit | 3f7e1e4b91889ac3aa6495cabb6d3a5072d9ca45 (patch) | |
tree | a86a132c3f7829674009dafe3f9946c8cbec8fd2 /src/interfaces/ecpg/ecpglib/misc.c | |
parent | 301194f8ead14c63d3bb7acac1cb70d43cb7adae (diff) | |
download | postgresql-3f7e1e4b91889ac3aa6495cabb6d3a5072d9ca45.tar.gz postgresql-3f7e1e4b91889ac3aa6495cabb6d3a5072d9ca45.zip |
Do not try to change a const variable.
Diffstat (limited to 'src/interfaces/ecpg/ecpglib/misc.c')
-rw-r--r-- | src/interfaces/ecpg/ecpglib/misc.c | 61 |
1 files changed, 29 insertions, 32 deletions
diff --git a/src/interfaces/ecpg/ecpglib/misc.c b/src/interfaces/ecpg/ecpglib/misc.c index 29c391612e2..3125a9065c8 100644 --- a/src/interfaces/ecpg/ecpglib/misc.c +++ b/src/interfaces/ecpg/ecpglib/misc.c @@ -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 |