[Mysql-cocoa-commits] CVS: SMySQL SMySQLConnection.h,1.6,1.7 SMySQLConnection.m,1.6,1.7 SMySQLResult
Brought to you by:
sergecohen
From: Serge C. <ser...@us...> - 2002-05-07 17:22:25
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv12656 Modified Files: SMySQLConnection.h SMySQLConnection.m SMySQLResult.m Log Message: Added a default to types switches... An error occured otherwise. Big bug on the fully embedded version of the framework. The other two versions work perfectly. Added function to get info on proto/client/host informations. Serge Cohen; MySQL Cocoa project, 7th May 2002. Index: SMySQLConnection.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLConnection.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SMySQLConnection.h 6 May 2002 09:58:27 -0000 1.6 --- SMySQLConnection.h 7 May 2002 17:22:21 -0000 1.7 *************** *** 96,100 **** --- 96,103 ---- "*/ + - (NSString *)clientInfo; + - (NSString *)hostInfo; - (NSString *)serverInfo; + - (NSNumber *)protoInfo; //- (BOOL)createDBWithName:(NSString *)dbName; Index: SMySQLConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLConnection.m,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SMySQLConnection.m 6 May 2002 09:58:27 -0000 1.6 --- SMySQLConnection.m 7 May 2002 17:22:21 -0000 1.7 *************** *** 396,400 **** if ((theQueryCode = mysql_query(mConnection, theCQuery)) == NULL) { ! theResult = [theResult initWithMySQLPtr:mConnection encoding:mEncoding]; } else { --- 396,406 ---- if ((theQueryCode = mysql_query(mConnection, theCQuery)) == NULL) { ! if (mysql_field_count(mConnection) != 0) { ! theResult = [theResult initWithMySQLPtr:mConnection encoding:mEncoding]; ! } ! else { ! NSLog (@"Query worked but gives no output\n"); ! [theResult init]; ! } } else { *************** *** 517,520 **** --- 523,544 ---- + - (NSString *)clientInfo + /*" + Return a string giving the client library version + "*/ + { + return [self stringWithCString:mysql_get_client_info()]; + } + + + - (NSString *)hostInfo + /*" + Return a string giving information on the host of the DB server. + "*/ + { + return [self stringWithCString:mysql_get_host_info(mConnection)]; + } + + - (NSString *)serverInfo /*" *************** *** 529,532 **** --- 553,565 ---- + - (NSNumber *)protoInfo + /*" + Return the number of the protocole used to transfer info from server to client + "*/ + { + return [NSNumber numberWithUnsignedInt:mysql_get_proto_info(mConnection)]; + } + + /* - (BOOL)createDBWithName:(NSString *)dbName *************** *** 592,598 **** "*/ { ! NSData * theData = [NSData dataWithBytes:theCString length:(strlen(theCString))]; ! NSString * theString = [[NSString alloc] initWithData:theData encoding:mEncoding]; if (theString) { [theString autorelease]; --- 625,636 ---- "*/ { ! NSData * theData; ! NSString * theString; + if (theCString == NULL) { + return @""; + } + theData = [NSData dataWithBytes:theCString length:(strlen(theCString))]; + theString = [[NSString alloc] initWithData:theData encoding:mEncoding]; if (theString) { [theString autorelease]; Index: SMySQLResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLResult.m,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SMySQLResult.m 6 May 2002 09:58:27 -0000 1.4 --- SMySQLResult.m 7 May 2002 17:22:21 -0000 1.5 *************** *** 215,218 **** --- 215,220 ---- theData[theLengths[i]] = '\0'; + // NSLog (@"in fetchRowAsDictionary : field type is %d, for column %d", (int)theField[i].type, (int)i); + switch (theField[i].type) { case FIELD_TYPE_TINY: *************** *** 277,280 **** --- 279,286 ---- [theCurrentObj autorelease]; break; + default: + NSLog (@"in fetchRowAsDictionary : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); + theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; + break; } [theDict setObject:theCurrentObj forKey:[mNames objectAtIndex:i]]; *************** *** 320,323 **** --- 326,332 ---- theData[theLengths[i]] = '\0'; + // NSLog (@"in fetchRowAsArray : field type is %d, for column %d", (int)theField[i].type, (int)i); + + switch (theField[i].type) { case FIELD_TYPE_TINY: *************** *** 382,385 **** --- 391,398 ---- [theCurrentObj autorelease]; break; + default: + NSLog (@"in fetchRowAsArray : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); + theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; + break; } [theArray addObject:theCurrentObj]; *************** *** 407,411 **** if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? ! return (mNames = [NSArray array]); } --- 420,424 ---- if (mResult == NULL) { // If no results, give an empty array. Maybe it's better to give a nil pointer? ! return (mNames = [[NSArray array] retain]); } *************** *** 415,419 **** for (i=0; i<theNumFields; i++) { NSString *theName = [self stringWithCString:theField[i].name]; ! [theNamesArray addObject:theName]; } --- 428,437 ---- for (i=0; i<theNumFields; i++) { NSString *theName = [self stringWithCString:theField[i].name]; ! if ((theName) && (![theName isEqualToString:@""])) { ! [theNamesArray addObject:theName]; ! } ! else { ! [theNamesArray addObject:[NSString stringWithFormat:@"Column %d", i]]; ! } } *************** *** 511,514 **** --- 529,536 ---- theType = @"newdate"; break; + default: + theType = @"unknown"; + NSLog (@"in fetchTypesAsArray : Unknown type for column %d of the SMySQLResult, type = %d", (int)i, (int)theField[i].type); + break; } [theTypesArray addObject:theType]; *************** *** 613,616 **** --- 635,642 ---- theType = @"newdate"; break; + default: + theType = @"unknown"; + NSLog (@"in fetchTypesAsDictionary : Unknown type for column %d of the SMySQLResult, type = %d", (int)i, (int)theField[i].type); + break; } [theTypesDict setObject:theType forKey:[mNames objectAtIndex:i]]; *************** *** 703,707 **** - (NSString *)description /*" ! Return a (long) string containing the table of results, first line being the fields name, next line(s) the row(s). Useful to have NSLog a SMySQLResult (example). "*/ { --- 729,733 ---- - (NSString *)description /*" ! Return a (long) string containing the table of results, first line being the fields name, next line(s) the row(s). Useful to have NSLog logging a SMySQLResult (example). "*/ { *************** *** 776,782 **** "*/ { ! NSData * theData = [NSData dataWithBytes:theCString length:(strlen(theCString))]; ! NSString * theString = [[NSString alloc] initWithData:theData encoding:mEncoding]; if (theString) { [theString autorelease]; --- 802,813 ---- "*/ { ! NSData * theData; ! NSString * theString; + if (theCString == NULL) { + return @""; + } + theData = [NSData dataWithBytes:theCString length:(strlen(theCString))]; + theString = [[NSString alloc] initWithData:theData encoding:mEncoding]; if (theString) { [theString autorelease]; |