Differences From Artifact [12a5dca2c4]:
- File src/PGConnection.m — part of check-in [fc8e42990e] at 2017-05-09 23:19:20 on branch trunk — Adjust to recent ObjFW changes (user: js, size: 5037) [annotate] [blame] [check-ins using]
To Artifact [b625cd9199]:
- File
src/PGConnection.m
— part of check-in
[6307a38198]
at
2017-05-10 23:46:05
on branch trunk
— Move private methods to separate headers
Also fixes a typo and adds two missing nullability annotations. (user: js, size: 5110) [annotate] [blame] [check-ins using]
1 2 3 4 5 6 7 8 | #import "PGConnection.h" #import "PGConnectionFailedException.h" #import "PGCommandFailedException.h" @implementation PGConnection @synthesize parameters = _parameters; | > > > | 1 2 3 4 5 6 7 8 9 10 11 | #import "PGConnection.h" #import "PGConnection+Private.h" #import "PGResult.h" #import "PGResult+Private.h" #import "PGConnectionFailedException.h" #import "PGCommandFailedException.h" @implementation PGConnection @synthesize parameters = _parameters; |
︙ | ︙ | |||
30 31 32 33 34 35 36 | if (connectionInfo != nil) [connectionInfo appendFormat: @" %@=%@", key, object]; else connectionInfo = [OFMutableString stringWithFormat: @"%@=%@", key, object]; } | | | | | | | | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | if (connectionInfo != nil) [connectionInfo appendFormat: @" %@=%@", key, object]; else connectionInfo = [OFMutableString stringWithFormat: @"%@=%@", key, object]; } if ((_connection = PQconnectdb([connectionInfo UTF8String])) == NULL) @throw [OFOutOfMemoryException exception]; if (PQstatus(_connection) == CONNECTION_BAD) @throw [PGConnectionFailedException exceptionWithConnection: self]; objc_autoreleasePoolPop(pool); } - (void)reset { PQreset(_connection); } - (void)close { if (_connection != NULL) PQfinish(_connection); _connection = NULL; } - (PGResult *)executeCommand: (OFConstantString *)command { PGresult *result = PQexec(_connection, [command UTF8String]); if (PQresultStatus(result) == PGRES_FATAL_ERROR) { PQclear(result); @throw [PGCommandFailedException exceptionWithConnection: self command: command]; } |
︙ | ︙ | |||
122 123 124 125 126 127 128 | } else if ([parameter isKindOfClass: [OFNull class]]) values[i++] = NULL; else values[i++] = [[parameter description] UTF8String]; } while ((parameter = va_arg(args, id)) != nil); | | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | } else if ([parameter isKindOfClass: [OFNull class]]) values[i++] = NULL; else values[i++] = [[parameter description] UTF8String]; } while ((parameter = va_arg(args, id)) != nil); result = PQexecParams(_connection, [command UTF8String], argsCount, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } objc_autoreleasePoolPop(pool); |
︙ | ︙ | |||
190 191 192 193 194 195 196 | values[i] = [value UTF8String]; [command appendFormat: @"$%zd", ++i]; } [command appendString: @")"]; | | | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | values[i] = [value UTF8String]; [command appendFormat: @"$%zd", ++i]; } [command appendString: @")"]; result = PQexecParams(_connection, [command UTF8String], (int)count, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } objc_autoreleasePoolPop(pool); |
︙ | ︙ | |||
218 219 220 221 222 223 224 | for (OFDictionary *row in rows) [self insertRow: row intoTable: table]; } - (PGconn *)PG_connection { | | | 221 222 223 224 225 226 227 228 229 230 | for (OFDictionary *row in rows) [self insertRow: row intoTable: table]; } - (PGconn *)PG_connection { return _connection; } @end |