From 23344580955d3fc6e85627966ea233c21b371e07 Mon Sep 17 00:00:00 2001 From: CaS Date: Thu, 22 Sep 2005 09:04:08 +0000 Subject: [PATCH] Fix cache item creation, add trivial cache test, tweak to avoid compiler warn. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@21735 72102866-910b-0410-8b05-ffd578937521 --- ECPG.pgm | 2 +- SQLClient.m | 4 ++-- testPostgres.m | 13 +++++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ECPG.pgm b/ECPG.pgm index b1ae544..d991607 100644 --- a/ECPG.pgm +++ b/ECPG.pgm @@ -809,7 +809,7 @@ static unsigned int trim(char *str) } } dst[dLen] = '\0'; - return dst; // Owned by autoreleased NSMutableData + return (const char*)dst; // Owned by autoreleased NSMutableData } - (NSData *) dataFromBlob: (const char *)blob diff --git a/SQLClient.m b/SQLClient.m index 22f8428..03559f0 100644 --- a/SQLClient.m +++ b/SQLClient.m @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include #include @@ -2063,7 +2063,7 @@ static void quoteString(NSMutableString *s) i = (SQLCItem*)NSAllocateObject(self, 0, NSDefaultMallocZone()); i->object = RETAIN(anObject); i->key = [aKey copy]; - return self; + return i; } - (void) dealloc { diff --git a/testPostgres.m b/testPostgres.m index 5171e29..15b3dc8 100644 --- a/testPostgres.m +++ b/testPostgres.m @@ -164,6 +164,9 @@ main() } else { + id r0; + id r1; + for (i = 0; i < 256; i++) { dbuf[i] = i; @@ -227,12 +230,18 @@ main() nil]; [db commit]; + r0 = [db cache: 1 query: @"select * from xxx", nil]; + r1 = [db cache: 1 query: @"select * from xxx", nil]; + NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed"); + sleep(1); records = [db query: @"select * from xxx", nil]; + NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed"); + [db execute: @"drop table xxx", nil]; - if ([records count] != 2) + if ([records count] != 3) { - NSLog(@"Expected 2 records but got %u", [records count]); + NSLog(@"Expected 3 records but got %u", [records count]); } else {