ObjPgSQL  Check-in [a19b24ae12]

Overview
Comment:Use ARC functions for RR
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256: a19b24ae129c1144fed2ba35d5a57ff2298b58ebb3c8f5071613e9efe67e4f63
User & Date: js 2025-04-19 13:34:33
Context
2025-04-19
13:34
Use ARC functions for RR Leaf check-in: a19b24ae12 user: js tags: trunk
2024-08-17
00:33
Include includedir in .oc file check-in: 7c54d67cf3 user: js tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/PGSQLConnection.m.

30
31
32
33
34
35
36
37

38
39
40
41
42
43
44
45
46

47
48
49
50
51
52
53
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45

46
47
48
49
50
51
52
53







-
+








-
+







- (instancetype)init
{
	self = [super init];

	@try {
		_parameters = [[OFDictionary alloc] init];
	} @catch (id e) {
		[self release];
		objc_release(self);
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_parameters release];
	objc_release(_parameters);

	[self close];

	[super dealloc];
}

- (void)connect

Changes to src/PGSQLResult.m.

22
23
24
25
26
27
28

29

30
31
32
33
34
35
36
22
23
24
25
26
27
28
29

30
31
32
33
34
35
36
37







+
-
+







#import "PGSQLResultRow+Private.h"

@implementation PGSQLResult
@synthesize pg_result = _result;

+ (instancetype)pg_resultWithResult: (PGresult *)result
{
	return objc_autoreleaseReturnValue(
	return [[[self alloc] pg_initWithResult: result] autorelease];
	    [[self alloc] pg_initWithResult: result]);
}

- (instancetype)pg_initWithResult: (PGresult *)result
{
	self = [super init];

	_result = result;

Changes to src/PGSQLResultRow.m.

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
91
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
91
92
93
94
95
96
97







+
-
+






+
-
-
-
+
+
+
+
+
+
+






-
+








@interface PGSQLResultRowObjectEnumerator: PGSQLResultRowEnumerator
@end

@implementation PGSQLResultRow
+ (instancetype)pg_rowWithResult: (PGSQLResult *)result row: (int)row
{
	return objc_autoreleaseReturnValue(
	return [[[self alloc] pg_initWithResult: result row: row] autorelease];
	    [[self alloc] pg_initWithResult: result row: row]);
}

- (instancetype)pg_initWithResult: (PGSQLResult *)result row: (int)row
{
	self = [super init];

	@try {
	_result = [result retain];
	_res = result.pg_result;
	_row = row;
		_result = objc_retain(result);
		_res = result.pg_result;
		_row = row;
	} @catch (id e) {
		objc_release(self);
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_result release];
	objc_release(_result);

	[super dealloc];
}

- (size_t)count
{
	int i, count, fields = PQnfields(_res);
111
112
113
114
115
116
117
118
119
120



121
122
123
124

125

126
127

128
129
130
131
132
133
134
117
118
119
120
121
122
123



124
125
126
127
128
129
130
131

132


133
134
135
136
137
138
139
140







-
-
-
+
+
+




+
-
+
-
-
+








	return convertType(_res, column,
	    [OFString stringWithUTF8String: PQgetvalue(_res, _row, column)]);
}

- (OFEnumerator *)keyEnumerator
{
	return [[[PGSQLResultRowKeyEnumerator alloc]
	    initWithResult: _result
		       row: _row] autorelease];
	return objc_autoreleaseReturnValue(
	    [[PGSQLResultRowKeyEnumerator alloc] initWithResult: _result
							    row: _row]);
}

- (OFEnumerator *)objectEnumerator
{
	return objc_autoreleaseReturnValue(
	return [[[PGSQLResultRowObjectEnumerator alloc]
	    [[PGSQLResultRowObjectEnumerator alloc] initWithResult: _result
	    initWithResult: _result
		       row: _row] autorelease];
							       row: _row]);
}

- (int)countByEnumeratingWithState: (OFFastEnumerationState *)state
			   objects: (id *)objects
			     count: (int)count
{
	int i, j;
161
162
163
164
165
166
167

168
169
170
171








172
173
174
175
176
177
178

179
180
181
182
183
184
185
167
168
169
170
171
172
173
174




175
176
177
178
179
180
181
182
183
184
185
186
187
188

189
190
191
192
193
194
195
196







+
-
-
-
-
+
+
+
+
+
+
+
+






-
+







@end

@implementation PGSQLResultRowEnumerator
- (instancetype)initWithResult: (PGSQLResult *)result row: (int)row
{
	self = [super init];

	@try {
	_result = [result retain];
	_res = result.pg_result;
	_row = row;
	_count = PQnfields(_res);
		_result = objc_retain(result);
		_res = result.pg_result;
		_row = row;
		_count = PQnfields(_res);
	} @catch (id e) {
		objc_release(self);
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_result release];
	objc_release(_result);

	[super dealloc];
}

- (void)reset
{
	_pos = 0;

Changes to src/exceptions/PGSQLException.m.

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
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







+
-
+












-
+




-
+








-
-
+
+







+ (instancetype)exception
{
	OF_UNRECOGNIZED_SELECTOR
}

+ (instancetype)exceptionWithConnection: (PGSQLConnection *)connection
{
	return objc_autoreleaseReturnValue(
	return [[[self alloc] initWithConnection: connection] autorelease];
	    [[self alloc] initWithConnection: connection]);
}

- (instancetype)init
{
	OF_INVALID_INIT_METHOD
}

- (instancetype)initWithConnection: (PGSQLConnection *)connection
{
	self = [super init];

	@try {
		_connection = [connection retain];
		_connection = objc_retain(connection);
		_errorMessage = [[OFString alloc]
		    initWithCString: PQerrorMessage([_connection pg_connection])
			   encoding: [OFLocale encoding]];
	} @catch (id e) {
		[self release];
		objc_release(self);
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_connection release];
	[_errorMessage release];
	objc_release(_connection);
	objc_release(_errorMessage);

	[super dealloc];
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"A PostgreSQL operation failed: %@",

Changes to src/exceptions/PGSQLExecuteCommandFailedException.m.

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
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







+
-
-
+
+















-
+








-
+











{
	OF_UNRECOGNIZED_SELECTOR
}

+ (instancetype)exceptionWithConnection: (PGSQLConnection *)connection
				command: (OFConstantString *)command
{
	return objc_autoreleaseReturnValue(
	return [[[self alloc] initWithConnection: connection
					 command: command] autorelease];
	    [[self alloc] initWithConnection: connection
				     command: command]);
}

- (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) {
		[self release];
		objc_release(self);
		@throw e;
	}

	return self;
}

- (void)dealloc
{
	[_command release];
	objc_release(_command);

	[super dealloc];
}

- (OFString *)description
{
	return [OFString stringWithFormat: @"A PostgreSQL command failed: %@\n"
					   @"Command: %@",
					   _errorMessage, _command];
}
@end