Comment: | Change prefix to PGSQL
Two letter prefixes are too risky to cause collisions. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
77c26b4fcecfc3e46c1e0b9412a9a88d |
User & Date: | js on 2024-08-11 18:00:52 |
Other Links: | manifest | tags |
2024-08-11
| ||
18:01 | Set version to 1.0 check-in: 33735ae0cd user: js tags: trunk, 1.0-release | |
18:00 | Change prefix to PGSQL check-in: 77c26b4fce user: js tags: trunk | |
17:48 | Remove .gitignore check-in: 6a6b563eda user: js tags: trunk | |
Modified Doxyfile from [d63473eed3] to [0f2e505861].
︙ | ︙ | |||
9 10 11 12 13 14 15 | HIDE_UNDOC_MEMBERS = YES TYPEDEF_HIDES_STRUCT = YES PREDEFINED = OF_DESIGNATED_INITIALIZER= \ OF_GENERIC(...)= \ OF_SENTINEL MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES | | | 9 10 11 12 13 14 15 16 17 | HIDE_UNDOC_MEMBERS = YES TYPEDEF_HIDES_STRUCT = YES PREDEFINED = OF_DESIGNATED_INITIALIZER= \ OF_GENERIC(...)= \ OF_SENTINEL MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES IGNORE_PREFIX = PGSQL EXTRACT_STATIC = yes |
Modified src/ObjPgSQL.h from [b8af5df6b9] to [c4c0222ebd].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLResult.h" #import "PGSQLResultRow.h" #import "PGSQLConnection.h" #import "PGSQLException.h" #import "PGSQLExecuteCommandFailedException.h" #import "PGSQLConnectionFailedException.h" |
Renamed and modified src/PGConnection+Private.h [0e21f3b90a] to src/PGSQLConnection+Private.h [9702597a7d].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLConnection.h" OF_ASSUME_NONNULL_BEGIN @interface PGSQLConnection () @property (readonly, nonatomic) PGconn *pg_connection; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/PGConnection.h [4e80eb06d8] to src/PGSQLConnection.h [a79bf6e7f3].
︙ | ︙ | |||
16 17 18 19 20 21 22 | * PERFORMANCE OF THIS SOFTWARE. */ #include <libpq-fe.h> #import <ObjFW/ObjFW.h> | | | | | | | | | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | * PERFORMANCE OF THIS SOFTWARE. */ #include <libpq-fe.h> #import <ObjFW/ObjFW.h> #import "PGSQLResult.h" OF_ASSUME_NONNULL_BEGIN /** @file */ /** * @brief A result row. */ typedef OFDictionary OF_GENERIC(OFString *, id) *PGSQLRow; /** * @class PGSQLConnection PGSQLConnection.h ObjPgSQL/ObjPgSQL.h * * @brief A connection to a database. */ @interface PGSQLConnection: OFObject { PGconn *_connection; OFDictionary OF_GENERIC(OFString *, OFString *) *_parameters; } /** * @brief The parameters for the database connection. See `PQconnectdb` in the * PostgreSQL documentation. */ @property (nonatomic, copy) OFDictionary OF_GENERIC(OFString *, OFString *) *parameters; /** * @brief Connects to the database. * * @throw PGSQLConnectionFailedException The connection failed */ - (void)connect; /** * @brief Resets the connection to the database. */ - (void)reset; /** * @brief Closes the connection to the database. */ - (void)close; /** * @brief Executes the specified command. * * @param command The command to execute * @return The result of the command, if any * @throw PGSQLCommandFailedException Executing the command failed. */ - (nullable PGSQLResult *)executeCommand: (OFConstantString *)command; /** * @brief Executes the specified command. * * @param command The command to execute * @param firstParameter First parameter for the command * @return The result of the command, if any * @throw PGSQLCommandFailedException Executing the command failed. */ - (nullable PGSQLResult *)executeCommand: (OFConstantString *)command parameters: (id)firstParameter, ... OF_SENTINEL; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/PGConnection.m [5e7a8f6854] to src/PGSQLConnection.m [40b1a4989d].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLConnection.h" #import "PGSQLConnection+Private.h" #import "PGSQLResult.h" #import "PGSQLResult+Private.h" #import "PGSQLConnectionFailedException.h" #import "PGSQLExecuteCommandFailedException.h" @implementation PGSQLConnection @synthesize pg_connection = _connection, parameters = _parameters; - (instancetype)init { self = [super init]; @try { |
︙ | ︙ | |||
69 70 71 72 73 74 75 | @"%@=%@", key, object]; } if ((_connection = PQconnectdb(connectionInfo.UTF8String)) == NULL) @throw [OFOutOfMemoryException exception]; if (PQstatus(_connection) == CONNECTION_BAD) | | | | | | | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | @"%@=%@", key, object]; } if ((_connection = PQconnectdb(connectionInfo.UTF8String)) == NULL) @throw [OFOutOfMemoryException exception]; if (PQstatus(_connection) == CONNECTION_BAD) @throw [PGSQLConnectionFailedException exceptionWithConnection: self]; objc_autoreleasePoolPop(pool); } - (void)reset { PQreset(_connection); } - (void)close { if (_connection != NULL) PQfinish(_connection); _connection = NULL; } - (PGSQLResult *)executeCommand: (OFConstantString *)command { PGresult *result = PQexec(_connection, command.UTF8String); if (PQresultStatus(result) == PGRES_FATAL_ERROR) { PQclear(result); @throw [PGSQLExecuteCommandFailedException exceptionWithConnection: self command: command]; } switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: return [PGSQLResult pg_resultWithResult: result]; case PGRES_COMMAND_OK: PQclear(result); return nil; default: PQclear(result); @throw [PGSQLExecuteCommandFailedException exceptionWithConnection: self command: command]; } } - (PGSQLResult *)executeCommand: (OFConstantString *)command parameters: (id)parameter, ... { void *pool = objc_autoreleasePoolPush(); PGresult *result; const char **values; va_list args, args2; int argsCount; |
︙ | ︙ | |||
163 164 165 166 167 168 169 | OFFreeMemory(values); } objc_autoreleasePoolPop(pool); switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: | | | | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | OFFreeMemory(values); } objc_autoreleasePoolPop(pool); switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: return [PGSQLResult pg_resultWithResult: result]; case PGRES_COMMAND_OK: PQclear(result); return nil; default: PQclear(result); @throw [PGSQLExecuteCommandFailedException exceptionWithConnection: self command: command]; } } @end |
Renamed and modified src/PGResult+Private.h [c69e339278] to src/PGSQLResult+Private.h [d2e2dec6a6].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLResult.h" OF_ASSUME_NONNULL_BEGIN @interface PGSQLResult () @property (readonly, nonatomic) PGresult *pg_result; + (instancetype)pg_resultWithResult: (PGresult *)result; - (instancetype)pg_initWithResult: (PGresult *)result; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/PGResult.h [2046b4f6dd] to src/PGSQLResult.h [62553c259f].
︙ | ︙ | |||
18 19 20 21 22 23 24 | #include <libpq-fe.h> #import <ObjFW/ObjFW.h> OF_ASSUME_NONNULL_BEGIN | | | | | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <libpq-fe.h> #import <ObjFW/ObjFW.h> OF_ASSUME_NONNULL_BEGIN @class PGSQLResultRow; /** * @class PGSQLResult PGSQLResult.h ObjPgSQL/ObjPgSQL.h * * @brief A PostgreSQL result. * * This is a regular OFArray, where each entry in the array represents a result * row. */ @interface PGSQLResult: OFArray OF_GENERIC(PGSQLResultRow *) { PGresult *_result; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/PGResult.m [6f8b3390f2] to src/PGSQLResult.m [dd60e56bcb].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLResult.h" #import "PGSQLResult+Private.h" #import "PGSQLResultRow.h" #import "PGSQLResultRow+Private.h" @implementation PGSQLResult @synthesize pg_result = _result; + (instancetype)pg_resultWithResult: (PGresult *)result { return [[[self alloc] pg_initWithResult: result] autorelease]; } |
︙ | ︙ | |||
52 53 54 55 56 57 58 | } - (id)objectAtIndex: (size_t)index { if (index > LONG_MAX || (long)index > PQntuples(_result)) @throw [OFOutOfRangeException exception]; | | | 52 53 54 55 56 57 58 59 60 61 | } - (id)objectAtIndex: (size_t)index { if (index > LONG_MAX || (long)index > PQntuples(_result)) @throw [OFOutOfRangeException exception]; return [PGSQLResultRow pg_rowWithResult: self row: (int)index]; } @end |
Renamed and modified src/PGResultRow+Private.h [4b3ecb6d0a] to src/PGSQLResultRow+Private.h [06b5a69ed1].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLResultRow.h" OF_ASSUME_NONNULL_BEGIN @interface PGSQLResultRow () + (instancetype)pg_rowWithResult: (PGSQLResult *)result row: (int)row; - (instancetype)pg_initWithResult: (PGSQLResult *)result row: (int)row; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/PGResultRow.h [1a14dcc36a] to src/PGSQLResultRow.h [cf19613225].
︙ | ︙ | |||
16 17 18 19 20 21 22 | * PERFORMANCE OF THIS SOFTWARE. */ #include <libpq-fe.h> #import <ObjFW/ObjFW.h> | | | | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | * PERFORMANCE OF THIS SOFTWARE. */ #include <libpq-fe.h> #import <ObjFW/ObjFW.h> #import "PGSQLResult.h" OF_ASSUME_NONNULL_BEGIN /** * @class PGSQLResult PGSQLResult.h ObjPgSQL/ObjPgSQL.h * * @brief A PostgreSQL result row. * * This is a regular OFDictionary, where each entry in the dictionary * represents a column of the result row. */ @interface PGSQLResultRow: OFDictionary OF_GENERIC(OFString *, id) { PGSQLResult *_result; PGresult *_res; int _row; } @end OF_ASSUME_NONNULL_END |
Renamed and modified src/PGResultRow.m [942a6e30f4] to src/PGSQLResultRow.m [459d0b869b].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLResultRow.h" #import "PGSQLResult+Private.h" static id convertType(PGresult *res, int column, OFString *string) { switch (PQftype(res, column)) { case 16: /* BOOLOID */ if ([string isEqual: @"t"]) |
︙ | ︙ | |||
42 43 44 45 46 47 48 | case 701: /* FLOAT8OID */ return [OFNumber numberWithDouble: string.doubleValue]; } return string; } | | | | | | | | | | 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 73 74 75 76 77 78 | case 701: /* FLOAT8OID */ return [OFNumber numberWithDouble: string.doubleValue]; } return string; } @interface PGSQLResultRowEnumerator: OFEnumerator { PGSQLResult *_result; PGresult *_res; int _row, _pos, _count; } - (instancetype)initWithResult: (PGSQLResult*)result row: (int)row; @end @interface PGSQLResultRowKeyEnumerator: PGSQLResultRowEnumerator @end @interface PGSQLResultRowObjectEnumerator: PGSQLResultRowEnumerator @end @implementation PGSQLResultRow + (instancetype)pg_rowWithResult: (PGSQLResult *)result row: (int)row { return [[[self alloc] pg_initWithResult: result row: row] autorelease]; } - (instancetype)pg_initWithResult: (PGSQLResult *)result row: (int)row { self = [super init]; _result = [result retain]; _res = result.pg_result; _row = row; |
︙ | ︙ | |||
111 112 113 114 115 116 117 | return convertType(_res, column, [OFString stringWithUTF8String: PQgetvalue(_res, _row, column)]); } - (OFEnumerator *)keyEnumerator { | | | | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | return convertType(_res, column, [OFString stringWithUTF8String: PQgetvalue(_res, _row, column)]); } - (OFEnumerator *)keyEnumerator { return [[[PGSQLResultRowKeyEnumerator alloc] initWithResult: _result row: _row] autorelease]; } - (OFEnumerator *)objectEnumerator { return [[[PGSQLResultRowObjectEnumerator alloc] initWithResult: _result row: _row] autorelease]; } - (int)countByEnumeratingWithState: (OFFastEnumerationState *)state objects: (id *)objects count: (int)count |
︙ | ︙ | |||
156 157 158 159 160 161 162 | state->itemsPtr = objects; state->mutationsPtr = (unsigned long *)self; return j; } @end | | | | 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | state->itemsPtr = objects; state->mutationsPtr = (unsigned long *)self; return j; } @end @implementation PGSQLResultRowEnumerator - (instancetype)initWithResult: (PGSQLResult *)result row: (int)row { self = [super init]; _result = [result retain]; _res = result.pg_result; _row = row; _count = PQnfields(_res); |
︙ | ︙ | |||
182 183 184 185 186 187 188 | - (void)reset { _pos = 0; } @end | | | | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | - (void)reset { _pos = 0; } @end @implementation PGSQLResultRowKeyEnumerator - (id)nextObject { if (_pos >= _count) return nil; while (_pos < _count && PQgetisnull(_res, _row, _pos)) _pos++; if (_pos >= _count) return nil; return [OFString stringWithUTF8String: PQfname(_res, _pos++)]; } @end @implementation PGSQLResultRowObjectEnumerator - (id)nextObject { id object; if (_pos >= _count) return nil; |
︙ | ︙ |
Renamed and modified src/exceptions/PGConnectionFailedException.h [1a9ea18919] to src/exceptions/PGSQLConnectionFailedException.h [92ce2ef6dd].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLException.h" OF_ASSUME_NONNULL_BEGIN /** * @class PGSQLConnectionFailedException PGSQLConnectionFailedException.h * PgSQL/PgSQL.h * * @brief An exception indicating that connecting to the database failed. */ @interface PGSQLConnectionFailedException: PGSQLException @end OF_ASSUME_NONNULL_END |
Renamed and modified src/exceptions/PGConnectionFailedException.m [eaac13221d] to src/exceptions/PGSQLConnectionFailedException.m [41cc2e2ed3].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLConnectionFailedException.h" @implementation PGSQLConnectionFailedException - (OFString *)description { return [OFString stringWithFormat: @"Establishing a PostgreSQL connection failed:\n%@\n" "Parameters: %@", _errorMessage, [_connection parameters]]; } @end |
Renamed and modified src/exceptions/PGException.h [6863b5251d] to src/exceptions/PGSQLException.h [84e9f655dc].
︙ | ︙ | |||
14 15 16 17 18 19 20 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import <ObjFW/ObjFW.h> | | | | | | | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import <ObjFW/ObjFW.h> #import "PGSQLConnection.h" OF_ASSUME_NONNULL_BEGIN /** * @class PGSQLException PGSQLException.h ObjPgSQL/ObjPgSQL.h * * @brief A PostgreSQL exception. */ @interface PGSQLException: OFException { PGSQLConnection *_connection; OFString *_errorMessage; } /** * @brief The connection for which the exception occurred. */ @property (readonly, nonatomic) PGSQLConnection *connection; /** * @brief An error message for the exception. */ @property (readonly, nonatomic) OFString *errorMessage; + (instancetype)exception OF_UNAVAILABLE; /** * @brief Creates a new PostgreSQL exception. * * @param connection The connection for which the exception occurred * @return A new, autoreleased PostgreSQL exception */ + (instancetype)exceptionWithConnection: (PGSQLConnection *)connection; - (instancetype)init OF_UNAVAILABLE; /** * @brief Initializes an already allocated PostgreSQL exception. * * @param connection The connection for which the exception occurred * @return An initialized PostgreSQL exception */ - (instancetype)initWithConnection: (PGSQLConnection *)connection OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/exceptions/PGException.m [abab265e43] to src/exceptions/PGSQLException.m [17f11a3e00].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLException.h" #import "PGSQLConnection+Private.h" @implementation PGSQLException @synthesize connection = _connection, errorMessage = _errorMessage; + (instancetype)exception { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithConnection: (PGSQLConnection *)connection { return [[[self alloc] initWithConnection: connection] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } - (instancetype)initWithConnection: (PGSQLConnection *)connection { self = [super init]; @try { _connection = [connection retain]; _errorMessage = [[OFString alloc] initWithCString: PQerrorMessage([_connection pg_connection]) |
︙ | ︙ |
Renamed and modified src/exceptions/PGExecuteCommandFailedException.h [675f91afaf] to src/exceptions/PGSQLExecuteCommandFailedException.h [7a760a9f51].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | > | | | | | > | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLException.h" OF_ASSUME_NONNULL_BEGIN /** * @class PGSQLExecuteCommandFailedException * PGSQLExecuteCommandFailedException.h * ObjPgSQL/ObjPgSQL.h * * @brief An exception indicating that executing a command failed. */ @interface PGSQLExecuteCommandFailedException: PGSQLException { OFConstantString *_command; } /** * @brief The command that could not be executed. */ @property (readonly, nonatomic) OFConstantString *command; + (instancetype)exceptionWithConnection: (PGSQLConnection *)connection OF_UNAVAILABLE; /** * @brief Creates a new execte command failed exception. * * @param connection The connection for which the command could not be executed * @param command The command which could not be executed * @return A new, autoreleased execute command failed exception */ + (instancetype)exceptionWithConnection: (PGSQLConnection *)connection command: (OFConstantString *)command; - (instancetype)initWithConnection: (PGSQLConnection *)connection OF_UNAVAILABLE; /** * @brief Initializes an already allocated execte command failed exception. * * @param connection The connection for which the command could not be executed * @param command The command which could not be executed * @return An initialized execute command failed exception */ - (instancetype)initWithConnection: (PGSQLConnection *)connection command: (OFConstantString *)command OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END |
Renamed and modified src/exceptions/PGExecuteCommandFailedException.m [f4ea4c984b] to src/exceptions/PGSQLExecuteCommandFailedException.m [0f00327522].
︙ | ︙ | |||
12 13 14 15 16 17 18 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ | | | | | | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import "PGSQLExecuteCommandFailedException.h" @implementation PGSQLExecuteCommandFailedException @synthesize command = _command; + (instancetype)exceptionWithConnection: (PGSQLConnection *)connection { OF_UNRECOGNIZED_SELECTOR } + (instancetype)exceptionWithConnection: (PGSQLConnection *)connection command: (OFConstantString *)command { return [[[self alloc] initWithConnection: connection command: command] autorelease]; } - (instancetype)initWithConnection: (PGSQLConnection *)connection { OF_INVALID_INIT_METHOD } - (instancetype)initWithConnection: (PGSQLConnection *)connection command: (OFConstantString *)command { self = [super initWithConnection: connection]; @try { _command = [command copy]; } @catch (id e) { |
︙ | ︙ |
Modified src/exceptions/meson.build from [674dc69ba9] to [ae614258d9].
1 | exceptions_sources = files( | | | | | 1 2 3 4 5 | exceptions_sources = files( 'PGSQLConnectionFailedException.m', 'PGSQLException.m', 'PGSQLExecuteCommandFailedException.m', ) |
Modified src/meson.build from [8256687f74] to [c0c95e2704].
1 2 3 4 5 | fs = import('fs') subdir('exceptions') sources = files( | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | fs = import('fs') subdir('exceptions') sources = files( 'PGSQLConnection.m', 'PGSQLResult.m', 'PGSQLResultRow.m', ) objpgsql = library('objpgsql', sources + exceptions_sources, include_directories: incdir, dependencies: [objfw_dep, libpq_dep], soversion: '0.0', |
︙ | ︙ |
Modified tests/Tests.m from [be5bedb02c] to [4eb664efe8].
︙ | ︙ | |||
14 15 16 17 18 19 20 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import <ObjFW/ObjFW.h> | | < | | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ #import <ObjFW/ObjFW.h> #import "ObjPgSQL.h" @interface Test: OFObject <OFApplicationDelegate> { PGSQLConnection *_connection; } @end OF_APPLICATION_DELEGATE(Test) @implementation Test - (void)applicationDidFinishLaunching: (OFNotification *)notification { OFString *username = [[OFApplication environment] objectForKey: @"USER"]; PGSQLResult *result; _connection = [[PGSQLConnection alloc] init]; [_connection setParameters: [OFDictionary dictionaryWithKeysAndObjects: @"user", username, @"dbname", username, nil]]; [_connection connect]; [_connection executeCommand: @"DROP TABLE IF EXISTS test"]; |
︙ | ︙ |