|
1 |
| -/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.44 2008/12/11 07:34:09 petere Exp $ */ |
| 1 | +/* $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/misc.c,v 1.45 2008/12/15 15:34:07 meskes Exp $ */ |
2 | 2 |
|
3 | 3 | #definePOSTGRES_ECPG_INTERNAL
|
4 | 4 | #include"postgres_fe.h"
|
@@ -241,49 +241,46 @@ void
|
241 | 241 | ecpg_log(constchar*format,...)
|
242 | 242 | {
|
243 | 243 | va_listap;
|
244 |
| -structsqlca_t*sqlca=ECPGget_sqlca(); |
245 |
| - |
246 |
| -/* internationalize the error message string */ |
247 |
| -format=ecpg_gettext(format); |
248 |
| - |
249 |
| -if (simple_debug) |
250 |
| -{ |
251 |
| -intbufsize=strlen(format)+100; |
252 |
| -char*f= (char*)malloc(bufsize); |
| 244 | +structsqlca_t*sqlca=ECPGget_sqlca(); |
| 245 | +intbufsize=strlen(format)+100; |
| 246 | +char*f= (char*)malloc(bufsize), |
| 247 | +*intl_format; |
253 | 248 |
|
254 |
| -if (f==NULL) |
255 |
| -return; |
| 249 | +if (!simple_debug||f==NULL) |
| 250 | +return; |
256 | 251 |
|
257 |
| -/* |
258 |
| - * regression tests set this environment variable to get the same |
259 |
| - * output for every run. |
260 |
| - */ |
261 |
| -if (ecpg_internal_regression_mode) |
262 |
| -snprintf(f,bufsize,"[NO_PID]: %s",format); |
263 |
| -else |
264 |
| -snprintf(f,bufsize,"[%d]: %s", (int)getpid(),format); |
| 252 | +/* internationalize the error message string */ |
| 253 | +intl_format=ecpg_gettext(format); |
| 254 | + |
| 255 | +/* |
| 256 | + * regression tests set this environment variable to get the same |
| 257 | + * output for every run. |
| 258 | + */ |
| 259 | +if (ecpg_internal_regression_mode) |
| 260 | +snprintf(f,bufsize,"[NO_PID]: %s",intl_format); |
| 261 | +else |
| 262 | +snprintf(f,bufsize,"[%d]: %s", (int)getpid(),intl_format); |
265 | 263 |
|
266 | 264 | #ifdefENABLE_THREAD_SAFETY
|
267 |
| -pthread_mutex_lock(&debug_mutex); |
| 265 | +pthread_mutex_lock(&debug_mutex); |
268 | 266 | #endif
|
269 | 267 |
|
270 |
| -va_start(ap,format); |
271 |
| -vfprintf(debugstream,f,ap); |
272 |
| -va_end(ap); |
| 268 | +va_start(ap,format); |
| 269 | +vfprintf(debugstream,f,ap); |
| 270 | +va_end(ap); |
273 | 271 |
|
274 |
| -/* dump out internal sqlca variables */ |
275 |
| -if (ecpg_internal_regression_mode) |
276 |
| -fprintf(debugstream,"[NO_PID]: sqlca: code: %ld, state: %s\n", |
277 |
| -sqlca->sqlcode,sqlca->sqlstate); |
| 272 | +/* dump out internal sqlca variables */ |
| 273 | +if (ecpg_internal_regression_mode) |
| 274 | +fprintf(debugstream,"[NO_PID]: sqlca: code: %ld, state: %s\n", |
| 275 | +sqlca->sqlcode,sqlca->sqlstate); |
278 | 276 |
|
279 |
| -fflush(debugstream); |
| 277 | +fflush(debugstream); |
280 | 278 |
|
281 | 279 | #ifdefENABLE_THREAD_SAFETY
|
282 |
| -pthread_mutex_unlock(&debug_mutex); |
| 280 | +pthread_mutex_unlock(&debug_mutex); |
283 | 281 | #endif
|
284 | 282 |
|
285 |
| -free(f); |
286 |
| -} |
| 283 | +free(f); |
287 | 284 | }
|
288 | 285 |
|
289 | 286 | void
|
|