/* Prototypes */
static int sql_store_result(SQLSOCK * sqlsocket, SQL_CONFIG *config);
static int sql_num_fields(SQLSOCK * sqlsocket, SQL_CONFIG *config);
+static int sql_close(SQLSOCK * sqlsocket, SQL_CONFIG *config);
/* Internal function. Return true if the postgresql status value
* indicates successful completion of the query. Return false otherwise
if (PQstatus(pg_sock->conn) == CONNECTION_BAD) {
radlog(L_ERR, "rlm_sql_postgresql: Couldn't connect socket to PostgreSQL server %s@%s:%s", config->sql_login, config->sql_server, config->sql_db);
radlog(L_ERR, "rlm_sql_postgresql: Postgresql error '%s'", PQerrorMessage(pg_sock->conn));
- PQfinish(pg_sock->conn);
+ sql_close(sqlsocket, config);
return SQL_DOWN;
}
if (!pg_sock->conn) return 0;
+ /* PQfinish also frees the memory used by the PGconn structure */
PQfinish(pg_sock->conn);
pg_sock->conn = NULL;