/*
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,
);
*/
columnName = "c_dir";
name = "DIR";
valueClassName = "NSString";
- externalType = "VARCHAR(255)";
+ externalType = "VARCHAR(300)";
allowsNull = N;
width = 255;
},
columnName = "c_cn";
name = "CN";
valueClassName = "NSString";
- externalType = "VARCHAR(40)";
+ externalType = "VARCHAR(80)";
allowsNull = N;
- width = 40;
+ width = 60;
},
{
columnName = "c_mailto";
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];
NSLog(@"opening channel ..");
-
+
+#if DEBUG
[ch setDebugEnabled:YES];
-
+#endif
+
if ([ch openChannel]) {
NSLog(@"channel is open");
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");
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]];
#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))
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
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;