Index: PGResultRow.m ================================================================== --- PGResultRow.m +++ PGResultRow.m @@ -106,10 +106,42 @@ { return [[[PGResultRowObjectEnumerator alloc] initWithResult: result row: row] autorelease]; } + +- (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state + objects: (id*)objects + count: (int)count +{ + int i, j; + + if (state->extra[0] == 0) { + state->extra[0] = 1; + state->extra[1] = PQnfields(res); + } + + if (count > SIZE_MAX - state->state) + @throw [OFOutOfRangeException exceptionWithClass: [self class]]; + + if (state->state + count > state->extra[1]) + count = state->extra[1] - state->state; + + for (i = j = 0; i < count; i++) { + if (PQgetisnull(res, row, state->state + i)) + continue; + + objects[j++] = [OFString stringWithUTF8String: + PQfname(res, state->state + i)]; + } + + state->state += count; + state->itemsPtr = objects; + state->mutationsPtr = (unsigned long*)self; + + return j; +} @end @implementation PGResultRowEnumerator - initWithResult: (PGResult*)result_ row: (int)row_ Index: test.m ================================================================== --- test.m +++ test.m @@ -39,12 +39,16 @@ intoTable: @"test"]; result = [connection executeCommand: @"SELECT * FROM test"]; of_log(@"%@", result); of_log(@"JSON: %@", [result JSONRepresentation]); + + for (id row in result) + for (id col in row) + of_log(@"%@", col); result = [connection executeCommand: @"SELECT COUNT(*) FROM test"]; of_log(@"%@", result); [OFApplication terminate]; } @end