pgpool2.git / summary / log / commit / refs

commit    d455fab61885a1665a85e8893db3003ab7d7c171
Author:   Tatsuo Ishii <ishii at sraoss.co.jp>
Date:     Fri Dec 25 01:58:51 2009 +0000

    Fix sloppy coding in parse_copy_data. Add error checking for
    malloc. Remove meaningless strerror.
    
    Fix sloppy coding in send_dealllocate. If failed to malloc, return -1,
    rather than horrible exit(1).


pool_process_query.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pool_process_query.c b/pool_process_query.c index cc3572d2c..bcd190fef 100644 --- a/pool_process_query.c +++ b/pool_process_query.c @@ -3524,6 +3524,9 @@ Portal *lookup_prepared_statement_by_portal(PreparedStatementList *p, const char return NULL; } +/* + * Send DEALLOCATE message to backend by using SimpleQuery. + */ static int send_deallocate(POOL_CONNECTION_POOL *backend, PreparedStatementList *p, int n) { @@ -3539,8 +3542,8 @@ static int send_deallocate(POOL_CONNECTION_POOL *backend, PreparedStatementList query = malloc(len); if (query == NULL) { - pool_error("send_deallocate: malloc failed: %s", strerror(errno)); - exit(1); + pool_error("send_deallocate: malloc failed"); + return -1; } sprintf(query, "DEALLOCATE \"%s\"", p_stmt->name); @@ -3566,6 +3569,11 @@ parse_copy_data(char *buf, int len, char delimiter, int col_id) char *str, *p = NULL; str = malloc(len + 1); + if (str == NULL) + { + pool_error("parse_copy_data: malloc failed"); + return NULL; + } /* buf is terminated by '\n'. */ /* skip '\n' in for loop. */ @@ -3607,7 +3615,7 @@ parse_copy_data(char *buf, int len, char delimiter, int col_id) p = malloc(j); if (p == NULL) { - pool_error("parse_copy_data: malloc failed: %s", strerror(errno)); + pool_error("parse_copy_data: malloc failed"); return NULL; } strcpy(p, str); [parent: d2037316c875]