Stricter error checking.

FossilOrigin-Name: cbc15fadc1bcf0dc8623f72e33d144803c4cf0d8bf740302a8915ae04cec1372
This commit is contained in:
Jonathan Schleifer 2012-10-08 18:53:08 +00:00
parent dee1a1ddde
commit d830fda977

View file

@ -70,11 +70,19 @@
command: command];
}
if (PQresultStatus(result) == PGRES_TUPLES_OK)
switch (PQresultStatus(result)) {
case PGRES_TUPLES_OK:
return [PGResult PG_resultWithResult: result];
PQclear(result);
return nil;
case PGRES_COMMAND_OK:
PQclear(result);
return nil;
default:
PQclear(result);
@throw [PGCommandFailedException
exceptionWithClass: [self class]
connection: self
command: command];
}
}
- (PGResult*)executeCommand: (OFConstantString*)command
@ -124,19 +132,19 @@
[pool release];
if (PQresultStatus(result) == PGRES_FATAL_ERROR) {
switch (PQresultStatus(result)) {
case PGRES_TUPLES_OK:
return [PGResult PG_resultWithResult: result];
case PGRES_COMMAND_OK:
PQclear(result);
return nil;
default:
PQclear(result);
@throw [PGCommandFailedException
exceptionWithClass: [self class]
connection: self
command: command];
}
if (PQresultStatus(result) == PGRES_TUPLES_OK)
return [PGResult PG_resultWithResult: result];
PQclear(result);
return nil;
}
- (void)insertRow: (OFDictionary*)row