aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/PostgresKit/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Frameworks/PostgresKit/Source')
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnection.h5
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnection.m10
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m11
-rw-r--r--Frameworks/PostgresKit/Source/FLXPostgresError.m6
-rw-r--r--Frameworks/PostgresKit/Source/PostgresKit.h1
5 files changed, 15 insertions, 18 deletions
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnection.h b/Frameworks/PostgresKit/Source/FLXPostgresConnection.h
index 20260818..51a6f9e5 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnection.h
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnection.h
@@ -23,6 +23,7 @@
#import "FLXPostgresTypeHandlerProtocol.h"
#import "FLXPostgresConnectionDelegate.h"
+@class FLXPostgresError;
@class FLXPostgresResult;
@class FLXPostgresStatement;
@class FLXPostgresConnectionParameters;
@@ -36,7 +37,6 @@
NSString *_database;
NSString *_password;
NSString *_socketPath;
- NSString *_lastErrorMessage;
NSString *_encoding;
const char **_connectionParamNames;
@@ -55,6 +55,7 @@
NSMutableDictionary *_typeMap;
+ FLXPostgresError *_lastError;
FLXPostgresConnectionParameters *_parameters;
NSObject <FLXPostgresConnectionDelegate> *_delegate;
@@ -69,7 +70,7 @@
@property (readwrite, retain) NSString *socketPath;
@property (readonly) NSString *encoding;
-@property (readonly) NSString *lastErrorMessage;
+@property (readonly) FLXPostgresError *lastError;
@property (readonly) NSStringEncoding stringEncoding;
@property (readonly) FLXPostgresConnectionParameters *parameters;
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnection.m b/Frameworks/PostgresKit/Source/FLXPostgresConnection.m
index 3bd24bb2..aed73ddf 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnection.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnection.m
@@ -75,7 +75,7 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
@synthesize useKeepAlive = _useKeepAlive;
@synthesize keepAliveInterval = _keepAliveInterval;
@synthesize lastQueryWasCancelled = _lastQueryWasCancelled;
-@synthesize lastErrorMessage = _lastErrorMessage;
+@synthesize lastError = _lastError;
@synthesize encoding = _encoding;
@synthesize stringEncoding = _stringEncoding;
@synthesize parameters = _parameters;
@@ -107,8 +107,8 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
_useKeepAlive = YES;
_keepAliveInterval = FLXPostgresConnectionDefaultKeepAlive;
+ _lastError = nil;
_connection = nil;
- _lastErrorMessage = nil;
_lastQueryWasCancelled = NO;
_stringEncoding = FLXPostgresConnectionDefaultStringEncoding;
@@ -343,9 +343,7 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
BOOL success = [_parameters loadParameters];
- if (!success) {
- NSLog(@"PostgresKit: Warning: Failed to load database parameters.");
- }
+ if (!success) NSLog(@"PostgresKit: Warning: Failed to load database parameters.");
}
/**
@@ -451,8 +449,8 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message
if (_connectionParamNames) free(_connectionParamNames);
if (_connectionParamValues) free(_connectionParamValues);
+ if (_lastError) [_lastError release], _lastError = nil;
if (_parameters) [_parameters release], _parameters = nil;
- if (_lastErrorMessage) [_lastErrorMessage release], _lastErrorMessage = nil;
[super dealloc];
}
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m
index 894338a7..79951f59 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryExecution.m
@@ -24,11 +24,12 @@
#import "FLXPostgresConnectionPrivateAPI.h"
#import "FLXPostgresConnectionTypeHandling.h"
#import "FLXPostgresConnectionDelegate.h"
+#import "FLXPostgresTypeHandlerProtocol.h"
#import "FLXPostgresConnection.h"
#import "FLXPostgresException.h"
#import "FLXPostgresResult.h"
-#import "FLXPostgresTypeHandlerProtocol.h"
#import "FLXPostgresStatement.h"
+#import "FLXPostgresError.h"
// Constants
static int FLXPostgresResultsAsBinary = 1;
@@ -249,12 +250,10 @@ FLXQueryParamData;
{
ExecStatusType status = PQresultStatus(result);
- if (status == PGRES_BAD_RESPONSE || status == PGRES_FATAL_ERROR) {
- NSString *error = [NSString stringWithUTF8String:PQresultErrorMessage(result)];
-
- if (_lastErrorMessage) [_lastErrorMessage release], _lastErrorMessage = nil;
+ if (status == PGRES_BAD_RESPONSE || status == PGRES_FATAL_ERROR) {
+ if (_lastError) [_lastError release], _lastError = nil;
- _lastErrorMessage = [[NSString alloc] initWithString:error];
+ _lastError = [[FLXPostgresError alloc] initWithResult:result];
PQclear(result);
diff --git a/Frameworks/PostgresKit/Source/FLXPostgresError.m b/Frameworks/PostgresKit/Source/FLXPostgresError.m
index 6a0a6210..22394900 100644
--- a/Frameworks/PostgresKit/Source/FLXPostgresError.m
+++ b/Frameworks/PostgresKit/Source/FLXPostgresError.m
@@ -114,10 +114,8 @@
* @return A string representing the error value. The caller is responsible for freeing the associated memory.
*/
- (NSString *)_extractErrorField:(int)field fromResult:(PGresult *)result
-{
- const char *errorData = PQresultErrorField(result, field);
-
- return [[NSString alloc] initWithBytes:errorData length:strlen(errorData) encoding:NSUTF8StringEncoding];
+{
+ return [[NSString alloc] initWithUTF8String:PQresultErrorField(result, field)];
}
#pragma mark -
diff --git a/Frameworks/PostgresKit/Source/PostgresKit.h b/Frameworks/PostgresKit/Source/PostgresKit.h
index cc9c7f13..40c86169 100644
--- a/Frameworks/PostgresKit/Source/PostgresKit.h
+++ b/Frameworks/PostgresKit/Source/PostgresKit.h
@@ -18,6 +18,7 @@
// License for the specific language governing permissions and limitations under
// the License.
+#import "FLXPostgresError.h"
#import "FLXPostgresResult.h"
#import "FLXPostgresStatement.h"
#import "FLXPostgresException.h"