pgpool2.git / summary / log / commit / refs

commit    a5d551d491975a0b5e2a07b655179462c0be29fb
Author:   Yoshiyuki Asaba <y-asaba at pgfoundry.org>
Date:     Tue Jan 09 19:02:50 2007 +0000

    Fix auto-deallocation. If a client used PDO interface, pgpool didn't
    clean prepared statement.


pool_process_query.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pool_process_query.c b/pool_process_query.c index 1e4f00fe4..7f8eb8f47 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -3044,7 +3044,6 @@ POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CO int sendlen; char *p; int i; - int name_len; char *name; for (i=0;i<NUM_BACKENDS;i++) @@ -3090,27 +3089,23 @@ POOL_STATUS SimpleForwardToBackend(char kind, POOL_CONNECTION *frontend, POOL_CO if (kind == 'P' && *p) { - name_len = strlen(p) + 3; - name = malloc(name_len); + name = strdup(p); if (name == NULL) { pool_error("SimpleForwardToBackend: malloc failed: %s", strerror(errno)); return POOL_END; } - sprintf(name, "\"%s\"", p); pending_function = add_prepared_list; pending_prepared_name = name; } else if (kind == 'C' && *p == 'S' && *(p + 1)) { - name_len = strlen(p + 1) + 3; - name = malloc(name_len); + name = strdup(p+1); if (name == NULL) { pool_error("SimpleForwardToBackend: malloc failed: %s", strerror(errno)); return POOL_END; } - sprintf(name, "\"%s\"", p + 1); pending_function = del_prepared_list; pending_prepared_name = name; } @@ -3978,14 +3973,14 @@ static int send_deallocate(POOL_CONNECTION_POOL *backend, PreparedStatementList if (p->cnt <= n) return 1; - len = strlen(p->stmt_list[n]) + 12; /* "DEALLOCATE " + '\0' */ + len = strlen(p->stmt_list[n]) + 14; /* "DEALLOCATE \"" + "\"" + '\0' */ query = malloc(len); if (query == NULL) { pool_error("send_deallocate: malloc failed: %s", strerror(errno)); exit(1); } - sprintf(query, "DEALLOCATE %s", p->stmt_list[n]); + sprintf(query, "DEALLOCATE \"%s\"", p->stmt_list[n]); if (SimpleQuery(NULL, backend, query) != POOL_CONTINUE) { free(query); [parent: f1ad5f5b8b45]