[Mysql-cocoa-commits] CVS: SMySQL SMySQLConnection.h,1.3,1.4 SMySQLConnection.m,1.3,1.4
Brought to you by:
sergecohen
From: Serge C. <ser...@us...> - 2002-04-10 18:38:17
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv30278 Modified Files: SMySQLConnection.h SMySQLConnection.m Log Message: Added an nil pointer check to selectDB, and a couple of warnings for similar problems. Serge Cohen; 10 April 2002. MySQL Cocoa project. Index: SMySQLConnection.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLConnection.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SMySQLConnection.h 21 Jan 2002 17:15:03 -0000 1.3 --- SMySQLConnection.h 10 Apr 2002 15:12:08 -0000 1.4 *************** *** 65,68 **** --- 65,69 ---- - (unsigned int)getLastErrorID; - (BOOL)isConnected; + - (BOOL)checkConnection; /*" Index: SMySQLConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLConnection.m,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SMySQLConnection.m 21 Jan 2002 17:15:03 -0000 1.3 --- SMySQLConnection.m 10 Apr 2002 15:12:08 -0000 1.4 *************** *** 202,207 **** --- 202,210 ---- - port is the TCP port to use to connect. If port = 0, uses the default port from mysql.h + + For the moment the implementation might not be safe if you have a nil pointer to one of the NSString* variables (underestand: I don't know what the result will be). "*/ { + #warning What to do if one of the string is a nil pointer? const char *theHost = [host UTF8String]; const char *theLogin = [login UTF8String]; *************** *** 234,239 **** - pass is the password corresponding to the user name ! "*/ { const char *theSocket = [socket UTF8String]; const char *theLogin = [login UTF8String]; --- 237,245 ---- - pass is the password corresponding to the user name ! ! For the moment the implementation might not be safe if you have a nil pointer to one of the NSString* variables (underestand: I don't know what the result will be). ! "*/ { + #warning What to do if one of the string is a nil pointer? const char *theSocket = [socket UTF8String]; const char *theLogin = [login UTF8String]; *************** *** 260,265 **** --- 266,278 ---- /*" Select a database to work with. The SMySQLConnection object needs to be properly inited and connected to a server. If a connection is not yet set or the selection of the database didn't worked, return NO. return yes in the normal case, where the database is properly selected. + + So far, if dbName is a nil pointer it will return NO (as if it cannot connect), most likely this will throw an exception in the future. "*/ { + if (dbName == nil) { + #warning Should throw an exception, illegal string pointer (nil) + // Here we should throw an exception, impossible to select a databse is the string is indeed a nil pointer + return NO; + } if (mConnected) { const char *theDBName = [dbName UTF8String]; *************** *** 303,306 **** --- 316,328 ---- return mConnected; } + + - (BOOL)checkConnection + /*" + Check if the connection to the server is still on; if not, tries to reconnect (changing no parameters from the MYSQL pointer). This method just uses mysql_ping(). + "*/ + { + return (BOOL)(! mysql_ping(mConnection)); + } + - (NSString *)prepareBinaryData:(NSData *)theData |