aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CMMCPConnection.m
Commit message (Collapse)AuthorAgeFilesLines
* Merge framework integration branch back to trunk. Summary of changes:stuconnolly2009-07-211-1364/+0
| | | | | | | | | | | | | | | - Includes all custom code from subclasses CMMCPConnection and CMMCPResult, meaning they have subsequently been removed from the project. - All previous Sequel Pro specific code in the above subclasses has been removed in favour of the delegate (currently set to TableDocumet) informing the framework of such information. - All references to CMMCPConnection and CMMCPResult have subsequently been changed to MCPConnection and MCPResult. - Framework includes MySQL 5.1.36 client libraries and source headers. - Framework is now built as a 4-way (32/64 bit, i386/PPC arch) binary. - All import references to <MCPKit_bundled/MCPKit_bundled.h> have been changed to <MCPKit/MCPKit.h>. - New script 'build-mysql-client.sh' can be used to build the MySQL client libraries from the MySQL source. See the script's header for a list of available options or run it with no arguments to display it's usage. Note that there are still a few changes to be made to the framework with regard to removing Sequel Pro specific calls to the delegate. These however can be made later on as they have no effect on functionality and are merely design changes. Also, note that any future development done on the framework should be made to be as 'generic' as possible, with no Sequel Pro specific references. This should allow the framework to be integrated into another project without the need for SP specific code.
* - Make the DBView window the document window. This allows the document to ↵rowanbeentje2009-07-151-5/+7
| | | | | | | | | | be closed when the window is closed, freeing the document's memory - Update a number of dealloc methods to include more retained memory, and to avoid releasing non-retained memory - Remove notification observers and delegates where appropriate to avoid issues after document closing - Fix a couple of memory leaks - Support window cascading for all windows past the first, using the first window as the autosave window
* - Fix connection controller errors with nil strings (bindings?), fixing ↵rowanbeentje2009-07-091-0/+37
| | | | | | | Issue #331 - Make the "optional" socket more optional: add a list of common socket file locations that are checked (instead of just /tmp/mysql.sock), including MAMP to address a common use case
* - Ensure that error IDs are available from CMMCPConnection after connection ↵rowanbeentje2009-07-081-0/+3
| | | | | | | or database selection problems - Detect connection errors due to "Access denied" problems and show a clearer, more appropriate error message
* Improve custom query timing and display:rowanbeentje2009-06-271-4/+8
| | | | | | | - Amend timing using clock() to timing based on mach_absolute_time() (see revision comment on Google code) - Ensure the time returned is for the requested query and not subsequent helper queries - Use NSNumberFormatter to return a localised "< 0.1 ms" rather than the hardcoded Euro-style "< 0,1 ms"
* - Set an appropriate error message if the MySQL connection could not be ↵rowanbeentje2009-06-251-1/+5
| | | | established because the required tunnel isn't available. Resolves Issue #310.
* - Modified titlebar display of SSH statusavenjamin2009-06-241-8/+20
|
* - Allow connections via SSH tunnels to reattempt using the specified host ↵rowanbeentje2009-06-211-11/+12
| | | | | | | | | if 127.0.0.1 was retried automatically. - Store the SSH debug logs and allow viewing on connection error - Clean up CMMCPConnections on connection failure - Fix connection keepalive instantiation
* • queryString: code cleaning and processing each encoding equallyBibiko2009-06-191-10/+3
| | | | | | | | - Since we are using mysql_real_query() there is no need to generate a \0 terminated cString. - The disadvantage of using UTF8String is that it returns NULL if the encoding fails. - To process each encoding equally we can now use [NSString dataUsingEncoding:enc allowLossyConversion:lossy]. In oder to avoid the overhead while calling it the following inline function is introduced: NSStringDataUsingLossyEncoding(aStr, enc, lossy) := [aStr dataUsingEncoding:enc allowLossyConversion:lossy] • import of CSV: code cleaned and optimized for speed a little
* • added to SPArrayAdditions.h: NSArrayObjectAtIndex() inline functionBibiko2009-06-181-8/+18
| | | | | | | | | - id o = NSArrayObjectAtIndex(anArray, index) :== id o = [anArray objectAtIndex:index] - this speed up it ~3µs per call - replaced that inline function for such calls within loops to speed up them • used IMP function pointers for keepAlive calls within queryString: • set -O3 (Fastest) compiler option • allow in preference pane "Tables" to set the Limit up to 50000
* • introduced inline function NSStringUTF8String() to SPStringAdditions.hBibiko2009-06-181-4/+6
| | | | | | - NSData *d = [aStr UTF8String]; :== NSData *d = NSStrignUTF8String(aStr) but a tick faster • implemented NSStringUTF8String() in queryString: and for the lex parser (syntax highlighting)
* • further tiny improvements for queryString's speedBibiko2009-06-181-4/+14
| | | | | | - cStringFromString function pointer is cached - if utf8 encoding make usage of UTF8String but implemented inside of queryString (otherwise no effect) • tiny code cosmetics
* • added: init consoleLoggingEnabled: for new connectionBibiko2009-06-181-0/+3
|
* • added to CMMCPConnection: observeValueForKeyPath:@"ConsoleEnableLogging"Bibiko2009-06-181-2/+14
| | | | | | - now [delegate willQueryString:] will only be called if user set ConsoleEnableLogging to YES (~8% faster) --Note: this option to disable logging should be placed in the Import dialog with default = NO for importing as well
* • some tiny improvements to speed up queryString:Bibiko2009-06-181-18/+16
| | | | | | | | | - cache the function pointer for delegate willPerformQuery: - if Console Log window is NOT visible suppress reloadData and scrolling to last line (this speeds it up remarkably); if user opens the Console log window it will be synchronized - timeIntervall for execution time will be divide by CLOCKS_PER_SEC in [NSString stringForTimeInterval] - removed for utf8 enc in cString the return UTF8String (no significant difference) • now execution time shows only the time for mysql_real_query
* • some improvement to speed up queryString:Bibiko2009-06-171-10/+17
| | | | | | | - caching of delegate && respondsToSelector - use clock() to calculate query's execution time • converting to cString: if utf8 encoding make usage of UTF8String • added to StringAddition to display µs for a timeIntervall
* Significant connection improvements:rowanbeentje2009-06-171-34/+92
| | | | | | | | | | - Restored MySQL 3 compatibility - max_packet_size details are now cached per connection for query speedup and to fix network recovery problems - Improved disconnection recovery - Errors during results fetching are correctly detected for the first time - Error strings are now correctly set in several places - The correct number of rows affected is now returned for queries which triggered reconnects or max_packet_size increases
* • added to CMMCPConnection:Bibiko2009-06-161-20/+77
| | | | | | | | | | | - register notification "SMySQLQueryWillBePerformed" to be able to identify the sender of the current query - (void)willPerformQuery:(NSNotification *)notification -- receives the "SMySQLQueryWillBePerformed" notification -- if CustomQuery was the sender retryAllowed will be set to NO • changed: now using mysql_real_query() because we've already calculated the length of the current query • changed: now the query length will be checked in beforehand against max_allowed_packet - if max_allowed_packet is editable increase it and reconnect - if not outputs an informative error alert
* Rework queryString:withEncoding:, and ensure memory is correctly released ↵rowanbeentje2009-06-151-37/+84
| | | | | | | | | | | where used in our overwrites: - Check allocated memory and ensure it is released in our code - Consolidate code controlling both an initial query and any retries following connection failures - Perform additional checking to ensure a connection error was the cause - Correctly capture any result sets after the max_allowed_packet setting was changed - Check and cache the error strings and numbers for the intended queries, not any helper queries, and return them when requested.
* • different log message for changing max_allowed_packet for increasing it ↵Bibiko2009-06-151-14/+20
| | | | | | | | and for resetting it (a bit more transparent info) - now also check the delegate if queryGaveError: method is implemented • while adding/updating a row to the db Table Content's pane now indicates that process better via spinning wheel • after TRUNCATE TABLE reload that table content
* • deleted the drag&drop feature of file path or content from ↵Bibiko2009-06-151-1/+3
| | | | | | | | | | | SPTextViewAdditions - that feature should be added by subclassing NSTextView • fixed focus setting of editSheet • fixed general issue if SP tries to execute a query which is longer than max_allowed_packet - now it reconnects after changing max_allowed_packet (if it's editable) - the user will be informed via a log entry about that change - the new max_allowed_packet size will be valid during the current session; after reconnection to that db the default size will be used
* Cleanups and improvements within queryString:encoding:rowanbeentje2009-06-151-35/+51
| | | | | | | - The correct result set is returned even if extra internal queries are used - The correct error message is written even if extra internal queries are used - If the mysql thread is altered as a result of a query - resetting the connection - the encoding details are now restored on the connection
* Add support for titlebar connection status images, and use for SSH tunnels.rowanbeentje2009-06-141-3/+21
| | | | | | | - Add view and code to support drawing a connection status icon at the left of the titlebar - Use for SSH tunnels; completes Issue #114. - Remove reference to an image resource "j" in the DBView - fixes console log errors.
* • fixed position for scanning error 2006 to increase max_allowed_packetBibiko2009-06-121-6/+6
|
* Fixes connection timeouts during queries of over three seconds, and speeds ↵rowanbeentje2009-06-121-74/+21
| | | | | | | up queries further (1.5x faster for short socket queries). Doing further research, it turns out that mysql_query should effectively lock the connection, and mysql_ping should not be performed while a query is active as mysql is specifically not thread-safe in this one regard. This fixes #293. However, it means that we will suffer from http://bugs.mysql.com/bug.php?id=9678 again; if we don't complete the framework integration before 0.9.6, we should roll back this patch and r831 to allow all connections to behave properly and avoid hangs.
* • fix to allow insert large blob dataBibiko2009-06-111-21/+35
| | | | | | If a query gave the error 2006 (server has gone away) try to increase max_allowed_packet - if the user has SUPER privileges - and redo the query. If max_allowed_packet was changed reset it to default after executing. In addition if error 2006 occurred and max_allowed_packet can't be set write an additional error message to the log "(Please check if query size < max_allowed_packet)". - 10MB of data are no problem - while trying to insert 67MB MySQL gave the error : ... X'(null)' plus malloc: mmap(size=141287424) failed (error code=12); can't allocate region
* • introduced these methods to CMMCPConnectionBibiko2009-06-111-0/+51
| | | | | | | - (int) getMaxAllowedPacket; - (BOOL) isMaxAllowedPacketEditable; - (int) setMaxAllowedPacketTo:(int)newSize;
* Effectively halve connection lag for queries, speeding up all queries and so ↵rowanbeentje2009-06-081-17/+108
| | | | | | | | | | | | interface responsiveness. - Rework [CMMCPConnection queryString:usingEncoding:] to no longer check the connection before every query. This removes a ping from the equation and therefore effectively halves connection lag. - Move the actual query to a thread (note this is *not* the long-desired multithreading!) to still correctly cope with http://bugs.mysql.com/bug.php?id=9678 . As soon as we upgrade the MySQL client libraries this can be removed, the code simplified, and a further processing speedup will be seen. - When testing a ~10,000 row CSV import (=10,000 queries), the following speedups were observed: - Local server, socket connection: 1.2x speedup - Remove server, 30ms ping: 1.85x speedup Slower connections will observe the biggest benefit from this commit.
* Further SSH tunnel improvements:rowanbeentje2009-06-061-2/+6
| | | | | | | | - Redesigned SSH key authentication dialog - Added ability to add SSH key passphrases to keychain (sharing details with system SSH) - SSH tunnels with keys which fail are now correctly restarted, interacting with the GUI as necessary - GUI interaction now performed on the main thread for increased stability
* Fixed some memory leaks found using llvm/clang. There are still some to fixbamse162009-06-051-2/+6
|
* Further SSH tunnel improvements, password handling improvements, and minor ↵rowanbeentje2009-06-041-0/+2
| | | | | | | | | | | | | bugfixes: - SSH tunnels can now correctly show dialogs for ssh queries, eg host key mismatches - SSH tunnels are now correctly closed by the document for connection failures - Keychain password item name and account generation has been moved to within the keychain class, to centralise generation for consistency - Keychain item names and accounts now correctly deal with nil values, allowing more keychain items to be read - "Add to favorites" button and menu item now correctly store passwords and SSH tunnel settings - Duplicating favorites in preferences now selects the newly created favorite instead of deselecting everything - Fixes an occasional crasher sometimes encountered in keychain usage
* - fixed bug with changing extra to auto_increment for a columnmtvee2009-06-031-1/+1
| | | | - small mem release issue in CMMCPConnection
* - Fix SSH tunnels on PPCrowanbeentje2009-06-031-0/+2
| | | | | | - Improve general SSH tunnel stability and automatic reconnection on failure - Improve handling of failed SSH tunnel passwords
* Add support for SSH tunnels, improve password security, and tweaks:rowanbeentje2009-05-281-47/+204
| | | | | | | | | | | | - Implementation of a new SPSSHTunnel class, designed to closely integrate SSH tunnels within Sequel Pro. - Integration of SPSSHTunnel - new connection methods using callbacks, and CMMCPConnection integration - Keychain class upgrade to include the new SPSSHTunnel keychain password helper on the trusted access list for new passwords - Keychain passwords are now held in memory/UI for only as long as necessary, increasing password security - Updated interface to enable/add SSH tunnel functionality - Remove old SSHTunnel class - Addition of new target for the SSH Tunnel password assistant, addition as a dependency of the main target, and addition to build script to copy into resources directory - Fix a keychain password deletion crash
* • fixed: serverVersionString retained and releasedBibiko2009-05-201-3/+3
|
* • fixed bug for getServerVersionStringBibiko2009-05-201-3/+5
| | | | - one has to loop over all rows of a CMMCPResult object or to set dataSeek to the end of that object to dealloc it
* More header updates for source files, including Subversion Id property.stuconnolly2009-05-191-1/+2
|
* Source tidy up including standard header for all source files.stuconnolly2009-05-181-1/+2
|
* - hide 'rename' context menu if selection is not a tablemtvee2009-05-181-1/+74
| | | | - added methods to CMMCPConnection to determine server major,minor,release version
* - Tweak code to use the new UseKeepAlive preference valuerowanbeentje2009-04-111-3/+4
| | | | | | | - Update a few pref checks which were using the old pref values still - Resort preference defaults to match layout in prefs, restore old default values for some keys - Restore missing defaults for new editor properties
* - If a connection is reestablished automatically by the mysql libraries, ↵rowanbeentje2009-04-091-4/+19
| | | | ensure the connection encoding is similarly reset. This addresses Issue #79.
* - Second part of r498: ensure that SQL imports are read in as UTF8, and ↵rowanbeentje2009-04-081-3/+35
| | | | queries are sent as UTF8, if possible; this correctly preserves encoding data when working with files export from Sequel Pro or via mysqldump, and attempts to fall back to the current connection encodings for other files. This should resolve Issue #116.
* - Select 'drop tables' option for MySQL export by default, to improve ↵rowanbeentje2009-04-061-0/+7
| | | | | | | backup-type process and more closely match mysqldump, and correctly drop views - Consistently set and restore the encoding appropriately for SQL import/export, and export to UTF8 files to correctly store all characters. Goes a good way towards addressing Issue #116.
* - Add a preference (currently with no UI) for connection timeoutrowanbeentje2009-03-281-24/+8
| | | | | | | - Improve connection error messages slightly. - Avoid reading prefs for every keepalive check - now sets connection timeout and keepalive interval on connection setup - Fix and extend connection checks to avoid showing extra errors when the connection has been closed
* SPSQLParser changes:rowanbeentje2009-03-191-2/+20
| | | | | | | | | | | | | | | | | | - Use method caches for oft-called functions, and support caching of chunks of the underlying string for string walking, resulting in an overall 1.3x-1.4x parsing speedup. - Improve handling of multi-character comment starts (eg / or -) at the very end of strings - When running splitString... methods return even empty strings for consistency. - Update TableDump and TableData to match new usage SPStringAddition changes: - Add a formatter for time intervals. CMMCPConnection changes: - Add support for timing queries CustomQuery and nib changes: - Change the "Run Queries" button to "Run All". - Add a "Run Current" button, which runs the query the text caret is currently positioned inside; if text is actually selected, this changes to "Run Selection". This addresses Issue #43. - Amend the "rows affected" string to better reflect the actual number of rows altered by several queries, show the query count if > 1, and display the overall execution time of the queries. This addresses Issue #142. - No longer execute blank strings as part of the custom query, preventing errors.
* Additional error checking, centralised connection keep-alive interval ↵rowanbeentje2009-03-091-10/+32
| | | | retrieval, and support for disabling keep-alive by setting the interval to 0.
* - Renames "Database Encoding" menu item in Database menu to "View Using ↵rowanbeentje2009-03-041-32/+61
| | | | | | | | Encoding" for clarity - Add support for EUC-KR (I think, unable to test), hopefully fixing Issue #149 - Add workaround for UTF8 via Latin 1, supporting viewing and editing of data added using broken clients/upgraded old Wordpress/etc.
* Rollback on newbie mistake...bamse162009-03-021-10/+1
|
* Better error handling of dump reading (checking for NSError object instead ↵bamse162009-03-021-0/+9
| | | | | | | | of content of read string) Raising error when trying to import empty CSV file.
* Applies connection checks and keepalive logic to select database/refresh ↵rowanbeentje2009-02-281-0/+31
| | | | databases queries. This fixes Issue #176.