[Mysql-cocoa-commits] CVS: SMySQL SMySQLConnection.h,1.8,1.9 SMySQLConnection.m,1.8,1.9 SMySQLResult
Brought to you by:
sergecohen
From: Serge C. <ser...@us...> - 2002-05-15 11:07:34
|
Update of /cvsroot/mysql-cocoa/SMySQL In directory usw-pr-cvs1:/tmp/cvs-serv4720 Modified Files: SMySQLConnection.h SMySQLConnection.m SMySQLResult.h SMySQLResult.m Log Message: Version 0.7.0 of the framework: - Removed the two connectTo... methods, replaced by a single connectWithLogin... method. - Changed listDBs... methods name to better reflect SQL language in the method name. - Added simple methods with less arguments as shortcuts to the listDBsLike... methods. - Added method to manage "process". - Reordered method in the files. Serge Cohen; MySQL Cocoa project, May 15th 2002. Index: SMySQLConnection.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLConnection.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SMySQLConnection.h 7 May 2002 18:43:58 -0000 1.8 --- SMySQLConnection.h 15 May 2002 11:07:30 -0000 1.9 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // #import <Foundation/Foundation.h> --- 21,26 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ ! #import <Foundation/Foundation.h> *************** *** 49,66 **** Initialisation "*/ ! - (id)init; // Port to 0 to use the default port ! - (id)initToHost:(NSString *)host withLogin:(NSString *)login password:(NSString *)pass usingPort:(int)port; ! - (id)initToSocket:(NSString *)socket withLogin:(NSString *)login password:(NSString *)pass; ! ! - (BOOL)setConnectionOption:(int)option withArgument:(id)arg; ! - (void)setEncoding:(NSStringEncoding) theEncoding; ! - (NSStringEncoding)encoding; // Port to 0 to use the default port ! - (BOOL)connectToHost:(NSString *)host withLogin:(NSString *)login password:(NSString *)pass usingPort:(int)port; ! - (BOOL)connectToSocket:(NSString *)socket withLogin:(NSString *)login password:(NSString *)pass; ! - (BOOL)selectDB:(NSString *)dbName; /*" --- 50,63 ---- Initialisation "*/ ! - (id) init; // Port to 0 to use the default port ! - (id) initToHost:(NSString *) host withLogin:(NSString *) login password:(NSString *) pass usingPort:(int) port; ! - (id) initToSocket:(NSString *) socket withLogin:(NSString *) login password:(NSString *) pass; + - (BOOL) setConnectionOption:(int) option withArgument:(id) arg; // Port to 0 to use the default port ! - (BOOL) connectWithLogin:(NSString *) login password:(NSString *) pass host:(NSString *) host port:(int) port socket:(NSString *) socket; ! - (BOOL) selectDB:(NSString *) dbName; /*" *************** *** 68,75 **** "*/ ! - (NSString *)getLastErrorMessage; ! - (unsigned int)getLastErrorID; ! - (BOOL)isConnected; ! - (BOOL)checkConnection; /*" --- 65,72 ---- "*/ ! - (NSString *) getLastErrorMessage; ! - (unsigned int) getLastErrorID; ! - (BOOL) isConnected; ! - (BOOL) checkConnection; /*" *************** *** 77,86 **** "*/ ! - (NSString *)prepareBinaryData:(NSData *)theData; ! - (SMySQLResult *)queryString:(NSString *)query; ! - (my_ulonglong)affectedRows; ! - (my_ulonglong)insertId; --- 74,83 ---- "*/ ! - (NSString *) prepareBinaryData:(NSData *) theData; ! - (SMySQLResult *) queryString:(NSString *) query; ! - (my_ulonglong) affectedRows; ! - (my_ulonglong) insertId; *************** *** 88,104 **** Getting description of the database structure "*/ ! - (SMySQLResult *)listDBs:(NSString *)dbsName; ! - (SMySQLResult *)listTables:(NSString *)tablesName; ! - (SMySQLResult *)listFields:(NSString *)fieldsName forTable:(NSString *)tableName; /*" ! Server information "*/ ! - (NSString *)clientInfo; ! - (NSString *)hostInfo; ! - (NSString *)serverInfo; ! - (NSNumber *)protoInfo; //- (BOOL)createDBWithName:(NSString *)dbName; --- 85,108 ---- Getting description of the database structure "*/ ! - (SMySQLResult *) listDBs; ! - (SMySQLResult *) listDBsLike:(NSString *) dbsName; ! - (SMySQLResult *) listTables; ! - (SMySQLResult *) listTablesLike:(NSString *) tablesName; ! // Next method uses SHOW TABLES FROM db to be sure that the db is not changed during this call. ! - (SMySQLResult *) listTablesFromDB:(NSString *) dbName like:(NSString *) tablesName; ! - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName; ! - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName like:(NSString *) fieldsName; /*" ! Server information and control "*/ ! - (NSString *) clientInfo; ! - (NSString *) hostInfo; ! - (NSString *) serverInfo; ! - (NSNumber *) protoInfo; ! - (SMySQLResult *) listProcesses; ! - (BOOL) killProcess:(unsigned long) pid; //- (BOOL)createDBWithName:(NSString *)dbName; *************** *** 109,120 **** "*/ ! - (void)disconnect; ! - (void)dealloc; /*" ! Private methods, internam use only "*/ ! - (const char *)cStringFromString:(NSString *)theString; ! - (NSString *)stringWithCString:(const char *)theCString; @end --- 113,128 ---- "*/ ! - (void) disconnect; ! - (void) dealloc; /*" ! String encoding concerns (c string type to NSString). ! It's unlikely that users of the framework needs to use these methods which are used internally "*/ ! - (void) setEncoding:(NSStringEncoding) theEncoding; ! - (NSStringEncoding) encoding; ! ! - (const char *) cStringFromString:(NSString *) theString; ! - (NSString *) stringWithCString:(const char *) theCString; @end Index: SMySQLConnection.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLConnection.m,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SMySQLConnection.m 7 May 2002 19:01:53 -0000 1.8 --- SMySQLConnection.m 15 May 2002 11:07:30 -0000 1.9 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // --- 21,25 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ *************** *** 48,54 **** + (NSDictionary *) getMySQLLocales ! /*"Get a proper Locale dictionary to use formater to parse strings from MySQL. ! ! For example strings representing dates... Should give a proper Locales for use with method such as NSDate::dateWithNaturalLanguageString: locales:"*/ { NSMutableDictionary *theLocalDict = [NSMutableDictionary dictionaryWithCapacity:12]; --- 48,55 ---- + (NSDictionary *) getMySQLLocales ! /*" ! Gets a proper Locale dictionary to use formater to parse strings from MySQL. ! For example strings representing dates should give a proper Locales for use with methods such as NSDate::dateWithNaturalLanguageString: locales: ! "*/ { NSMutableDictionary *theLocalDict = [NSMutableDictionary dictionaryWithCapacity:12]; *************** *** 61,69 **** + (NSStringEncoding) encodingForMySQLEncoding:(const char *) mysqlEncoding ! /*"From the name a charset in mysql format return the proper NSStringEncoding corresponding to this charset. ! This method is not complete for the moment, I hope people using non "supported" encoding will addd them when one needs it, and send me back the modification. ! As off version 4.0 of MySQL, choice in : big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1 latin1_de latin2 latin5 sjis swe7 tis620 ujis usa7 win1250 win1251ukr "*/ { --- 62,72 ---- + (NSStringEncoding) encodingForMySQLEncoding:(const char *) mysqlEncoding ! /*" ! Gets a proper NSStringEncoding according to the given MySQL charset. ! MySQL 4.0 offers this charsets: big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1 latin1_de latin2 latin5 sjis swe7 tis620 ujis usa7 win1250 win1251ukr + + WARNING : incomplete implementation. Please, send your fixes. "*/ { *************** *** 93,97 **** + (NSStringEncoding) defaultMySQLEncoding ! /*"Return the default charset of the library mysqlclient used. "*/ { --- 96,101 ---- + (NSStringEncoding) defaultMySQLEncoding ! /*" ! Returns the default charset of the library mysqlclient used. "*/ { *************** *** 100,104 **** ! - (id)init /*" Initialise a MySQLConnection without making a connection, most likely useless, except with #{setConnectionOption:withArgument:}. --- 104,108 ---- ! - (id) init /*" Initialise a MySQLConnection without making a connection, most likely useless, except with #{setConnectionOption:withArgument:}. *************** *** 112,132 **** return nil; } ! mEncoding = NSISOLatin1StringEncoding; return self; } ! - (id)initToHost:(NSString *)host withLogin:(NSString *)login password:(NSString *)pass usingPort:(int)port ! /*"Initialise a connection using a #{TCP/IP connection} with the given parameters (except if host is set to !{localhost}, in which case uses the default) - host is the hostname or IP adress - - login is the user name - - pass is the password corresponding to the user name - - port is the TCP port to use to connect. If port = 0, uses the default port from mysql.h "*/ { self = [super init]; mEncoding = NSISOLatin1StringEncoding; --- 116,136 ---- return nil; } ! // mEncoding = NSISOLatin1StringEncoding; ! mEncoding = [SMySQLConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; return self; } ! - (id) initToHost:(NSString *) host withLogin:(NSString *) login password:(NSString *) pass usingPort:(int) port ! /*" ! Initialise a connection using a #{TCP/IP connection} with the given parameters (except if host is set to !{localhost}, in which case uses the default) - host is the hostname or IP adress - login is the user name - pass is the password corresponding to the user name - port is the TCP port to use to connect. If port = 0, uses the default port from mysql.h "*/ { + #warning What happens when inited twice the NSObject? self = [super init]; mEncoding = NSISOLatin1StringEncoding; *************** *** 137,142 **** } else { - // else the object has never been inited... - self = [super init]; } --- 141,144 ---- *************** *** 149,168 **** } ! [self connectToHost:host withLogin:login password:pass usingPort:port]; ! return self; ! } ! - (id)initToSocket:(NSString *)socket withLogin:(NSString *)login password:(NSString *)pass ! /*"Initialise a connection using a #{unix socket} with the given parameters - socket is the path to the socket - - login is the user name - - pass is the password corresponding to the user name ! "*/ { self = [super init]; mEncoding = NSISOLatin1StringEncoding; --- 151,169 ---- } ! [self connectWithLogin:login password:pass host:host port:port socket:nil]; ! return self; } ! - (id) initToSocket:(NSString *) socket withLogin:(NSString *) login password:(NSString *) pass ! /*" ! Initialise a connection using a #{unix socket} with the given parameters - socket is the path to the socket - login is the user name - pass is the password corresponding to the user name ! "*/ { + #warning What happens when inited twice the NSObject? self = [super init]; mEncoding = NSISOLatin1StringEncoding; *************** *** 173,178 **** } else { - // else the object has never been inited... - self = [super init]; } --- 174,177 ---- *************** *** 185,194 **** } ! [self connectToSocket:socket withLogin:login password:pass]; return self; } ! - (BOOL)setConnectionOption:(int)option withArgument:(id)arg /*" #{NOT YET IMPLEMENTED} --- 184,193 ---- } ! [self connectWithLogin:login password:pass host:NULL port:0 socket:socket]; return self; } ! - (BOOL) setConnectionOption:(int) option withArgument:(id) arg /*" #{NOT YET IMPLEMENTED} *************** *** 213,255 **** } - - (void)setEncoding:(NSStringEncoding) theEncoding - /*" - Select the encoding used by the server for data transfert. This is usefull for the output NSString (query result) to be Ok even for character which are not ASCII - NB: The character set (encoding) used by the db is passed to the SMySQLConnection object upon connection, so most likely the encoding (from -encoding) method is already the proper one. That is to say : It's unlikeley you need to use this method, and if ever you use it, do it at your own risks. - "*/ - { - mEncoding = theEncoding; - } - - - - (NSStringEncoding)encoding - /*" - Get back the encoding for the server connection - "*/ - { - return mEncoding; - } - ! // Give 0 for port to connect to default port ! - (BOOL)connectToHost:(NSString *)host withLogin:(NSString *)login password:(NSString *)pass usingPort:(int)port /*" ! The method used by #{initToHost:withLogin:password:usingPort:}. Same information and use of the parameters: ! ! - host is the hostname or IP adress ! ! - login is the user name ! ! - pass is the password corresponding to the user name ! - 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]; ! const char *thePass = [pass UTF8String]; void *theRet; --- 212,235 ---- } ! - (BOOL) connectWithLogin:(NSString *) login password:(NSString *) pass host:(NSString *) host port:(int) port socket:(NSString *) socket /*" ! The method used by #{initToHost:withLogin:password:usingPort:} and #{initToSocket:withLogin:password:}. Same information and use of the parameters: ! - login is the user name ! - pass is the password corresponding to the user name ! - host is the hostname or IP adress ! - port is the TCP port to use to connect. If port = 0, uses the default port from mysql.h ! - socket is the path to the socket (for the localhost) ! The socket is used if the host is set to !{@"localhost"}, to an empty or a !{nil} string ! 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 *theLogin = [self cStringFromString:login]; ! const char *theHost = [self cStringFromString:host]; ! const char *thePass = [self cStringFromString:pass]; ! const char *theSocket = [self cStringFromString:socket]; void *theRet; *************** *** 262,302 **** } ! theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, port, kSMySQLConnectionDefaultSocket, kSMySQL_default_option); ! if (theRet != mConnection) { ! return mConnected = NO; } ! mEncoding = [SMySQLConnection encodingForMySQLEncoding:mysql_character_set_name(mConnection)]; ! return mConnected = YES; ! } ! ! ! - (BOOL)connectToSocket:(NSString *)socket withLogin:(NSString *)login password:(NSString *)pass ! /*" ! The method used by #{initToSocket:withLogin:password:}. Same information and use of the parameters: ! ! - socket is the path to the socket ! ! - login is the user name ! ! - 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]; ! const char *thePass = [pass UTF8String]; ! void *theRet; ! ! if (mConnected) { ! // Disconnect if it was already connected ! mysql_close(mConnection); ! mConnection = NULL; ! mConnected = NO; ! [self init]; } ! theRet = mysql_real_connect(mConnection, NULL, theLogin, thePass, NULL, 0, theSocket, kSMySQL_default_option); if (theRet != mConnection) { return mConnected = NO; --- 242,253 ---- } ! if ([host isEqualToString:@""]) { ! theHost = NULL; } ! if (theSocket == NULL) { ! theSocket = kSMySQLConnectionDefaultSocket; } ! theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, port, theSocket, kSMySQL_default_option); if (theRet != mConnection) { return mConnected = NO; *************** *** 307,313 **** ! - (BOOL)selectDB:(NSString *)dbName /*" ! 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. --- 258,266 ---- ! - (BOOL) selectDB:(NSString *) dbName /*" ! Selects 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 work, returns NO. Returns YES in normal cases 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. *************** *** 316,320 **** 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; } --- 269,273 ---- if (dbName == nil) { #warning Should throw an exception, illegal string pointer (nil) ! // Here we should throw an exception, impossible to select a databse if the string is indeed a nil pointer return NO; } *************** *** 329,335 **** ! - (NSString *)getLastErrorMessage /*" ! Return a string with the last MySQL error message on the connection. "*/ { --- 282,288 ---- ! - (NSString *) getLastErrorMessage /*" ! Returns a string with the last MySQL error message on the connection. "*/ { *************** *** 342,348 **** } ! - (unsigned int)getLastErrorID /*" ! Return the ErrorID of the last MySQL error on the connection. "*/ { --- 295,301 ---- } ! - (unsigned int) getLastErrorID /*" ! Returns the ErrorID of the last MySQL error on the connection. "*/ { *************** *** 353,359 **** } ! - (BOOL)isConnected /*" ! Return YES if the SMySQLConnection is connected to a DB, NO otherwise. "*/ { --- 306,312 ---- } ! - (BOOL) isConnected /*" ! Returns YES if the SMySQLConnection is connected to a DB, NO otherwise. "*/ { *************** *** 363,367 **** - (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(). "*/ { --- 316,322 ---- - (BOOL)checkConnection /*" ! Checks 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(). "*/ { *************** *** 370,374 **** ! - (NSString *)prepareBinaryData:(NSData *)theData /*" Takes a NSData object and transform it in a proper string for sending to the server in between quotes. --- 325,329 ---- ! - (NSString *) prepareBinaryData:(NSData *) theData /*" Takes a NSData object and transform it in a proper string for sending to the server in between quotes. *************** *** 386,393 **** } ! - (SMySQLResult *)queryString:(NSString *)query /*" Takes a query string and return an SMySQLResult object holding the result of the query. The returned SMySQLResult is not retained, the client is responsible for that (it's autoreleased before being returned) "*/ { --- 341,350 ---- } ! ! - (SMySQLResult *) queryString:(NSString *) query /*" Takes a query string and return an SMySQLResult object holding the result of the query. The returned SMySQLResult is not retained, the client is responsible for that (it's autoreleased before being returned) + Note that if you want to use this method with binary data (in the query), you should use !{prepareBinaryData:} to include the binary data in the query string. "*/ { *************** *** 415,421 **** } ! - (my_ulonglong)affectedRows /*" ! Return the number of affected rows by the last query. "*/ { --- 372,378 ---- } ! - (my_ulonglong) affectedRows /*" ! Returns the number of affected rows by the last query. "*/ { *************** *** 426,430 **** } ! - (my_ulonglong)insertId /*" If the last query was an insert in a table having a autoindex column, returns the id (autoindexed field) of the last row inserted. --- 383,388 ---- } ! ! - (my_ulonglong) insertId /*" If the last query was an insert in a table having a autoindex column, returns the id (autoindexed field) of the last row inserted. *************** *** 438,445 **** ! - (SMySQLResult *)listDBs:(NSString *)dbsName /*" ! Return a list of database which name correspond to the string dbsName. The comparison is done with wild card extension : % and _. The result should correspond to the queryString:@"SHOW databases [LIKE wild]"; but implemented with mysql_list_dbs. ! If an empty string of nil is passed as dbsName, all databases will be shown. "*/ { --- 396,414 ---- ! - (SMySQLResult *) listDBs /*" ! Just a fast wrapper for the more complex !{listDBsWithPattern:} method. ! "*/ ! { ! return [self listDBsLike:nil]; ! } ! ! ! - (SMySQLResult *) listDBsLike:(NSString *) dbsName ! /*" ! Returns a list of database which name correspond to the SQL regular expression in 'pattern'. ! The comparison is done with wild card extension : % and _. ! The result should correspond to the queryString:@"SHOW databases [LIKE wild]"; but implemented with mysql_list_dbs. ! If an empty string or nil is passed as pattern, all databases will be shown. "*/ { *************** *** 471,478 **** ! - (SMySQLResult *)listTables:(NSString *)tablesName /*" From within a database, give back the list of table which name correspond to tablesName (with wild card %, _ extension). Correspond to queryString:@"SHOW tables [LIKE wild]"; uses mysql_list_tables function. ! If an empty string of nil is passed as tablesName, all tables will be shown. "*/ { --- 440,457 ---- ! - (SMySQLResult *) listTables ! /*" ! Make sure a DB is selected (with !{selectDB} method) first. ! "*/ ! { ! return [self listTablesLike:nil]; ! } ! ! ! - (SMySQLResult *) listTablesLike:(NSString *) tablesName /*" From within a database, give back the list of table which name correspond to tablesName (with wild card %, _ extension). Correspond to queryString:@"SHOW tables [LIKE wild]"; uses mysql_list_tables function. ! If an empty string or nil is passed as tablesName, all tables will be shown. ! WARNING: #{produce an error if no databases are selected} (with !{selectDB:} for example). "*/ { *************** *** 504,511 **** ! - (SMySQLResult *)listFields:(NSString *)fieldsName forTable:(NSString *)tableName /*" ! Show all the fields of the table tableName which name correspond to fieldsName (with wild card expansion : %,_). Indeed, and as recommanded from mysql reference, this method is NOT using mysql_list_fields but the queryString:@"" method. ! If an empty string of nil is passed as fieldsName, all fields (of tableName) will be returned. "*/ { --- 483,521 ---- ! - (SMySQLResult *) listTablesFromDB:(NSString *) dbName like:(NSString *) tablesName /*" ! List tables in DB specified by dbName and corresponding to pattern. ! This method indeed issues a !{SHOW TABLES FROM dbName LIKE ...} query to the server. ! This is done this way to make sure the selected DB is not changed by this method. ! "*/ ! { ! SMySQLResult *theResult; ! ! if ((tablesName == nil) || ([tablesName isEqualToString:@""])) { ! NSString *theQuery = [NSString stringWithFormat:@"SHOW TABLES FROM %@", dbName]; ! theResult = [self queryString:theQuery]; ! } ! else { ! NSString *theQuery = [NSString stringWithFormat:@"SHOW COLUMNS FROM %@ LIKE '%@'", dbName, tablesName]; ! theResult = [self queryString:theQuery]; ! } ! return theResult; ! } ! ! ! - (SMySQLResult *)listFieldsFromTable:(NSString *)tableName ! /*" ! Just a fast wrapper for the more complex list !{listFieldsWithPattern:forTable:} method. ! "*/ ! { ! return [self listFieldsFromTable:tableName like:nil]; ! } ! ! ! - (SMySQLResult *) listFieldsFromTable:(NSString *) tableName like:(NSString *) fieldsName ! /*" ! Show all the fields of the table tableName which name correspond to pattern (with wild card expansion : %,_). ! Indeed, and as recommanded from mysql reference, this method is NOT using mysql_list_fields but the !{queryString:} method. ! If an empty string or nil is passed as fieldsName, all fields (of tableName) will be returned. "*/ { *************** *** 524,530 **** ! - (NSString *)clientInfo /*" ! Return a string giving the client library version "*/ { --- 534,540 ---- ! - (NSString *) clientInfo /*" ! Returns a string giving the client library version. "*/ { *************** *** 533,539 **** ! - (NSString *)hostInfo /*" ! Return a string giving information on the host of the DB server. "*/ { --- 543,549 ---- ! - (NSString *) hostInfo /*" ! Returns a string giving information on the host of the DB server. "*/ { *************** *** 542,548 **** ! - (NSString *)serverInfo /*" ! Return server information. "*/ { --- 552,558 ---- ! - (NSString *) serverInfo /*" ! Returns a string giving the server version. "*/ { *************** *** 554,560 **** ! - (NSNumber *)protoInfo /*" ! Return the number of the protocole used to transfer info from server to client "*/ { --- 564,570 ---- ! - (NSNumber *) protoInfo /*" ! Returns the number of the protocole used to transfer info from server to client "*/ { *************** *** 563,566 **** --- 573,597 ---- + - (SMySQLResult *) listProcesses + /*" + Lists active process + "*/ + { + SMySQLResult *theResult = [SMySQLResult alloc]; + MYSQL_RES *theResPtr; + + if (theResPtr = mysql_list_processes(mConnection)) { + [theResult initWithResPtr:theResPtr encoding:mEncoding]; + } else { + [theResult init]; + } + + if (theResult) { + [theResult autorelease]; + } + return theResult; + } + + /* - (BOOL)createDBWithName:(NSString *)dbName *************** *** 584,590 **** ! - (void)disconnect /*" ! Disconnect a connected SMySQLConnection object; used by #{-dealloc} method. "*/ { --- 615,634 ---- ! - (BOOL) killProcess:(unsigned long) pid /*" ! Kills the process with the given pid. ! The users needs the #{Process_priv} privilege. ! "*/ ! { ! int theErrorCode; ! ! theErrorCode = mysql_kill(mConnection, pid); ! return (theErrorCode) ? NO : YES; ! } ! ! ! - (void) disconnect ! /*" ! Disconnects a connected SMySQLConnection object; used by #{-dealloc} method. "*/ { *************** *** 608,619 **** ! - (const char *)cStringFromString:(NSString *)theString /*" ! For internal use only. Transform a NSString to a C type string (ended with \0) using ethe character set from the SMySQLConnection. Lossy conversions are enabled. "*/ { ! NSMutableData *theData = [NSMutableData dataWithData:[theString dataUsingEncoding:mEncoding allowLossyConversion:YES]]; [theData increaseLengthBy:1]; return (const char *)[theData bytes]; --- 652,690 ---- ! - (void) setEncoding:(NSStringEncoding) theEncoding /*" ! Sets the encoding used by the server for data transfert. ! Used to make sure the output of the query result is ok even for non-ascii characters ! The character set (encoding) used by the db is passed to the SMySQLConnection object upon connection, ! so most likely the encoding (from -encoding) method is already the proper one. ! That is to say : It's unlikely you will need to call this method directly, and #{if ever you use it, do it at your own risks}. ! "*/ ! { ! mEncoding = theEncoding; ! } ! ! ! - (NSStringEncoding) encoding ! /*" ! Gets the encoding for the connection ! "*/ ! { ! return mEncoding; ! } ! ! ! - (const char *) cStringFromString:(NSString *) theString ! /*" ! For internal use only. Transforms a NSString to a C type string (ending with \0) using the character set from the SMySQLConnection. Lossy conversions are enabled. "*/ { ! NSMutableData *theData; + if (! theString) { + return (const char *)NULL; + } + + theData = [NSMutableData dataWithData:[theString dataUsingEncoding:mEncoding allowLossyConversion:YES]]; [theData increaseLengthBy:1]; return (const char *)[theData bytes]; *************** *** 621,627 **** ! - (NSString *)stringWithCString:(const char *)theCString /*" ! Return a NSString from a C style string encoded with the character set of theSMySQLConnection. "*/ { --- 692,698 ---- ! - (NSString *) stringWithCString:(const char *) theCString /*" ! Returns a NSString from a C style string encoded with the character set of theSMySQLConnection. "*/ { Index: SMySQLResult.h =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLResult.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SMySQLResult.h 7 May 2002 18:43:58 -0000 1.5 --- SMySQLResult.h 15 May 2002 11:07:30 -0000 1.6 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // #import <Foundation/Foundation.h> --- 21,26 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ ! #import <Foundation/Foundation.h> Index: SMySQLResult.m =================================================================== RCS file: /cvsroot/mysql-cocoa/SMySQL/SMySQLResult.m,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SMySQLResult.m 7 May 2002 17:22:21 -0000 1.5 --- SMySQLResult.m 15 May 2002 11:07:30 -0000 1.6 *************** *** 21,25 **** // More info at <http://mysql-cocoa.sourceforge.net/> // ! // #import "SMySQLConnection.h" --- 21,26 ---- // More info at <http://mysql-cocoa.sourceforge.net/> // ! // $Id$ ! #import "SMySQLConnection.h" *************** *** 790,795 **** "*/ { ! NSMutableData *theData = [NSMutableData dataWithData:[theString dataUsingEncoding:mEncoding allowLossyConversion:YES]]; [theData increaseLengthBy:1]; return (const char *)[theData bytes]; --- 791,801 ---- "*/ { ! NSMutableData *theData; + if (! theString) { + return (const char *)NULL; + } + + theData = [NSMutableData dataWithData:[theString dataUsingEncoding:mEncoding allowLossyConversion:YES]]; [theData increaseLengthBy:1]; return (const char *)[theData bytes]; |