From 3ea75b1932e544724ec0ab9abe0b2c3500168e14 Mon Sep 17 00:00:00 2001 From: znek Date: Fri, 21 May 2004 18:48:37 +0000 Subject: [PATCH] Bugfixes git-svn-id: http://svn.opengroupware.org/SOGo/trunk@6 d1b88da0-ebda-0310-925b-ed51d893ca5b --- db/tests/znek/connection.plist | 2 +- db/tests/znek/inserts.eomodel | 10 ++++----- db/tests/znek/inserts.m | 20 ++++++++++++------ db/tests/znek/lmail.m | 37 ++++++++++++++++++++++++---------- 4 files changed, 46 insertions(+), 23 deletions(-) diff --git a/db/tests/znek/connection.plist b/db/tests/znek/connection.plist index 51b7d87e..0e6cda4f 100644 --- a/db/tests/znek/connection.plist +++ b/db/tests/znek/connection.plist @@ -1,5 +1,5 @@ { - hostName = "localhost"; + hostName = "agenor-db"; userName = "agenor"; password = ""; databaseName = "SOGo1"; diff --git a/db/tests/znek/inserts.eomodel b/db/tests/znek/inserts.eomodel index 745d6443..163da293 100644 --- a/db/tests/znek/inserts.eomodel +++ b/db/tests/znek/inserts.eomodel @@ -2,8 +2,8 @@ /* CREATE TABLE SOGo_test ( c_id INT PRIMARY KEY, - c_dir VARCHAR(255) NOT NULL, - c_cn VARCHAR(40) NOT NULL, + c_dir VARCHAR(300) NOT NULL, + c_cn VARCHAR(80) NOT NULL, c_mailto VARCHAR(120) NOT NULL, ); */ @@ -40,7 +40,7 @@ columnName = "c_dir"; name = "DIR"; valueClassName = "NSString"; - externalType = "VARCHAR(255)"; + externalType = "VARCHAR(300)"; allowsNull = N; width = 255; }, @@ -48,9 +48,9 @@ columnName = "c_cn"; name = "CN"; valueClassName = "NSString"; - externalType = "VARCHAR(40)"; + externalType = "VARCHAR(80)"; allowsNull = N; - width = 40; + width = 60; }, { columnName = "c_mailto"; diff --git a/db/tests/znek/inserts.m b/db/tests/znek/inserts.m index f639e65f..7287d994 100644 --- a/db/tests/znek/inserts.m +++ b/db/tests/znek/inserts.m @@ -38,10 +38,15 @@ int main(int argc, char **argv, char **env) { NSLog(@"found no PostgreSQL adaptor .."); exit(1); } - + +#if DEBUG NSLog(@"got adaptor %@", a); +#endif [a setConnectionDictionary:conDict]; +#if DEBUG NSLog(@"got adaptor with condict %@", a); +#endif + ctx = [a createAdaptorContext]; ch = [ctx createAdaptorChannel]; @@ -54,9 +59,11 @@ int main(int argc, char **argv, char **env) { NSLog(@"opening channel .."); - + +#if DEBUG [ch setDebugEnabled:YES]; - +#endif + if ([ch openChannel]) { NSLog(@"channel is open"); @@ -95,7 +102,7 @@ int main(int argc, char **argv, char **env) { NS_DURING if([ctx beginTransaction]) { - expr = @"CREATE TABLE SOGo_test (c_id INT PRIMARY KEY, c_dir VARCHAR(255) NOT NULL, c_cn VARCHAR(40) NOT NULL, c_mailto VARCHAR(120) NOT NULL);"; + expr = @"CREATE TABLE SOGo_test (c_id INT PRIMARY KEY, c_dir VARCHAR(300) NOT NULL, c_cn VARCHAR(80) NOT NULL, c_mailto VARCHAR(120) NOT NULL);"; if([ch evaluateExpression:expr]) { if([ctx commitTransaction]) { NSLog(@"CREATE TABLE - committed"); @@ -131,15 +138,16 @@ int main(int argc, char **argv, char **env) { attributes = [e attributesUsedForInsert]; attributesNames = [e attributesNamesUsedForInsert]; - for(i = 0; i < 10; i++) { + for(i = 0; i < 10000; i++) { NSDictionary *pdata, *values; NSMutableDictionary *row; NSAutoreleasePool *lpool = [[NSAutoreleasePool alloc] init]; NSNumber *newPK; pdata = [allPersonRecords randomObject]; +#if DEBUG NSLog(@"pdata: %@", pdata); - +#endif newPK = [NSNumber numberWithUnsignedInt:i + 1]; row = [pdata mutableCopy]; [row setObject:newPK forKey:[[e primaryKeyAttributeNames] lastObject]]; diff --git a/db/tests/znek/lmail.m b/db/tests/znek/lmail.m index 5fb42715..dced4901 100644 --- a/db/tests/znek/lmail.m +++ b/db/tests/znek/lmail.m @@ -7,7 +7,7 @@ #define DEBUG 0 -#define ALL_RECORDS @"/tmp/all.nsarray" +#define ALL_RECORDS @"/home/znek/all-BALI.plist" #ifndef MAX #define MAX(a,b) (((a)>(b))?(a):(b)) @@ -17,8 +17,8 @@ int main(int argc, char **argv, char **env) { NSAutoreleasePool *pool; NSArray *records; - unsigned int i, count, maxLength; - NSString *longestMailto; + unsigned int i, count, maxMailtoLength, maxDNLength, maxCNLength; + NSString *longestMailto, *longestCN, *longestDN; pool = [[NSAutoreleasePool alloc] init]; #if LIB_FOUNDATION_LIBRARY @@ -27,19 +27,34 @@ int main(int argc, char **argv, char **env) { records = [NSArray arrayWithContentsOfFile:ALL_RECORDS]; count = [records count]; - maxLength = 0; + maxMailtoLength = 0; + maxDNLength = maxCNLength = 0; for(i = 0; i < count; i++) { - NSString *mailto; + NSDictionary *d; + NSString *value; unsigned length; - mailto = [[records objectAtIndex:i] objectForKey:@"mailto"]; - length = [mailto length]; - maxLength = MAX(maxLength, length); - if(length == maxLength) - longestMailto = mailto; + d = [records objectAtIndex:i]; + value = [d objectForKey:@"mailto"]; + length = [value length]; + maxMailtoLength = MAX(maxMailtoLength, length); + if(length == maxMailtoLength) + longestMailto = value; + + value = [d objectForKey:@"DIR"]; + length = [value length]; + maxDNLength = MAX(maxDNLength, length); + if(length == maxDNLength) + longestDN = value; + + value = [d objectForKey:@"CN"]; + length = [value length]; + maxCNLength = MAX(maxCNLength, length); + if(length == maxCNLength) + longestCN = value; } - printf("\nTotal: %d\nMaxlength: %d\nlongest: %s\n", count, maxLength, [longestMailto cString]); + printf("\nTotal: %d\nMaxMailtoLength: %d\nlongest: %s\nmaxDN: %d\nlongest: %s\nmaxCN: %d\nlongest: %s\n", count, maxMailtoLength, [longestMailto cString], maxDNLength, [longestDN cString], maxCNLength, [longestCN cString]); [pool release]; exit(0); return 0; -- 2.39.5