From: Tatsuo Ishii Date: Thu, 12 Nov 2009 07:04:03 +0000 (+0000) Subject: Prepare for bind_rewrite_timestamp() returns NULL case. This could X-Git-Tag: V2_3~24 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=7fe9460985088eda9cd49de00a239d019ec4004f;p=pgpool2.git Prepare for bind_rewrite_timestamp() returns NULL case. This could happen if SELECT now() is called inside an aborted transaction. Fix SimpleForwardToBackend free rewrite_msg too early. --- diff --git a/pool_process_query.c b/pool_process_query.c index 27a3a3142..3d6bce95b 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -1948,8 +1948,12 @@ POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CO /* rewrite bind message */ if (REPLICATION && portal && portal->num_tsparams > 0) { - p = rewrite_msg = bind_rewrite_timestamp(backend, portal, p, &len); - sendlen = htonl(len + 4); + rewrite_msg = bind_rewrite_timestamp(backend, portal, p, &len); + if (rewrite_msg != NULL) + { + p = rewrite_msg; + sendlen = htonl(len + 4); + } } } @@ -1976,7 +1980,6 @@ POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CO } } } - free(rewrite_msg); if (kind == 'B') /* Bind message */ { @@ -2004,6 +2007,7 @@ POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CO free(portal->portal_name); portal->portal_name = strdup(portal_name); } + free(rewrite_msg); } /* Close message with prepared statement name. */