From 16dc91b0e7bd740c51eac580da2e956197811143 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 18 May 2013 01:37:42 +0000 Subject: [PATCH] Add -[PGConnection close]. FossilOrigin-Name: 52b090139e1672d79c01e1a7e3d681cd342101efbe04a6c1d4f395c6b65c797a --- PGConnection.h | 1 + PGConnection.m | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/PGConnection.h b/PGConnection.h index 3c9bd42..d314266 100644 --- a/PGConnection.h +++ b/PGConnection.h @@ -18,6 +18,7 @@ - (OFDictionary*)parameters; - (void)connect; - (void)reset; +- (void)close; - (PGResult*)executeCommand: (OFConstantString*)command; - (PGResult*)executeCommand: (OFConstantString*)command parameters: (id)firstParameter, ... OF_SENTINEL; diff --git a/PGConnection.m b/PGConnection.m index ebdba94..60d8c3c 100644 --- a/PGConnection.m +++ b/PGConnection.m @@ -8,8 +8,7 @@ { [_parameters release]; - if (_connnection != NULL) - PQfinish(_connnection); + [self close]; [super dealloc]; } @@ -58,6 +57,14 @@ PQreset(_connnection); } +- (void)close +{ + if (_connnection != NULL) + PQfinish(_connnection); + + _connnection = NULL; +} + - (PGResult*)executeCommand: (OFConstantString*)command { PGresult *result = PQexec(_connnection, [command UTF8String]);