aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorrowanbeentje <rowan@beent.je>2010-03-25 01:13:12 +0000
committerrowanbeentje <rowan@beent.je>2010-03-25 01:13:12 +0000
commit32e858b26923b371a93e800687a13edf1254e445 (patch)
treeff2bac08381f0bd54e01c2f3f756c9fe5a2e2507 /Source
parent5061643c1bf92a3583e4ede059951e1f17befac9 (diff)
downloadsequelpro-32e858b26923b371a93e800687a13edf1254e445.tar.gz
sequelpro-32e858b26923b371a93e800687a13edf1254e445.tar.bz2
sequelpro-32e858b26923b371a93e800687a13edf1254e445.zip
- Make [MCPConnection getLastErrorMessage] more consistent by always returning nil if no error occurred (previously a blank string was returned most of the time)
- Add a new (BOOL)[MCPConnection queryErrored] method, changing all error message checks to use it for clarity
Diffstat (limited to 'Source')
-rw-r--r--Source/CustomQuery.m8
-rw-r--r--Source/SPDatabaseData.m3
-rw-r--r--Source/SPExportController.m2
-rw-r--r--Source/SPProcessListController.m4
-rw-r--r--Source/SPTableData.m14
-rw-r--r--Source/SPTableRelations.m9
-rw-r--r--Source/SPTableTriggers.m7
-rw-r--r--Source/SPUserManager.m2
-rw-r--r--Source/TableContent.m14
-rw-r--r--Source/TableDocument.m30
-rw-r--r--Source/TableDump.m24
-rw-r--r--Source/TableSource.m20
-rw-r--r--Source/TablesList.m24
13 files changed, 77 insertions, 84 deletions
diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m
index 6fe9bf8a..b6512f5a 100644
--- a/Source/CustomQuery.m
+++ b/Source/CustomQuery.m
@@ -579,7 +579,7 @@
[streamingResult release];
// Store any error messages
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] || [mySQLConnection queryCancelled]) {
+ if ([mySQLConnection queryErrored] || [mySQLConnection queryCancelled]) {
NSString *errorString;
if ([mySQLConnection queryCancelled]) {
@@ -1672,7 +1672,7 @@
// [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
// Check for errors while UPDATE
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"Couldn't write field.\nMySQL said: %@", @"message of panel when error while updating field to db"), [mySQLConnection getLastErrorMessage]]);
@@ -1808,7 +1808,7 @@
{
queryIsTableSorter = NO;
- if(![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
sortColumn = nil;
return;
}
@@ -2565,7 +2565,7 @@
// search via: HELP 'searchString'
theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"HELP '%@'", [searchString stringByReplacingOccurrencesOfString:@"'" withString:@"\\'"]]];
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""])
+ if ([mySQLConnection queryErrored])
{
// if an error or HELP is not supported fall back to online search but
// don't open it if autoHelp is enabled
diff --git a/Source/SPDatabaseData.m b/Source/SPDatabaseData.m
index 4e40f998..8c4935d9 100644
--- a/Source/SPDatabaseData.m
+++ b/Source/SPDatabaseData.m
@@ -433,8 +433,7 @@ const SPDatabaseCharSets charsets[] =
MCPResult *result = [connection queryString:query];
- // Log any errors
- if ([[connection getLastErrorMessage] isEqualToString:@""]) {
+ if (![connection queryErrored]) {
[result dataSeek:0];
for (NSInteger i = 0; i < [result numOfRows]; i++)
diff --git a/Source/SPExportController.m b/Source/SPExportController.m
index caa504e7..dce7857b 100644
--- a/Source/SPExportController.m
+++ b/Source/SPExportController.m
@@ -445,7 +445,7 @@
MCPStreamingResult *queryResultStreaming = [connection streamingQueryString:[NSString stringWithFormat:@"SELECT * FROM %@", [tableName backtickQuotedString]] useLowMemoryBlockingStreaming:useLowMemoryBlockingStreaming];
// Note any errors during retrieval
- if (![[connection getLastErrorMessage] isEqualToString:@""]) {
+ if ([connection queryErrored]) {
[errors appendString:[NSString stringWithFormat:@"%@\n", [connection getLastErrorMessage]]];
}
diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m
index ab0ae931..d655e776 100644
--- a/Source/SPProcessListController.m
+++ b/Source/SPProcessListController.m
@@ -449,7 +449,7 @@
[connection queryString:[NSString stringWithFormat:@"KILL QUERY %lu", (unsigned long)processId]];
// Check for errors
- if (![[connection getLastErrorMessage] isEqualToString:@""]) {
+ if ([connection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Unable to kill query", @"error killing query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"An error occured while attempting to kill the query associated with connection %lu.\n\nMySQL said: %@", @"error killing query informative message"), (unsigned long)processId, [connection getLastErrorMessage]]);
}
@@ -467,7 +467,7 @@
[connection queryString:[NSString stringWithFormat:@"KILL CONNECTION %lu", (unsigned long)processId]];
// Check for errors
- if (![[connection getLastErrorMessage] isEqualToString:@""]) {
+ if ([connection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Unable to kill connection", @"error killing connection message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"An error occured while attempting to kill connection %lu.\n\nMySQL said: %@", @"error killing query informative message"), (unsigned long)processId, [connection getLastErrorMessage]]);
}
diff --git a/Source/SPTableData.m b/Source/SPTableData.m
index 2b07fbce..1807b66e 100644
--- a/Source/SPTableData.m
+++ b/Source/SPTableData.m
@@ -330,7 +330,7 @@
[theResult setReturnDataAsStrings:YES];
// Check for any errors, but only display them if a connection still exists
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
SPBeginAlertSheet(NSLocalizedString(@"Error retrieving table information", @"error retrieving table information message"), NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], self, nil, nil, nil,
@@ -598,7 +598,7 @@
[theResult setReturnDataAsStrings:YES];
// Check for any errors, but only display them if a connection still exists
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
SPBeginAlertSheet(NSLocalizedString(@"Error retrieving table information", @"error retrieving table information message"), NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], self, nil, nil, nil,
@@ -692,7 +692,7 @@
[theResult setReturnDataAsStrings:YES];
// Check for any errors, but only display them if a connection still exists
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], self, nil, nil, nil,
@@ -711,7 +711,7 @@
[theResult setReturnDataAsStrings:YES];
// Check for any errors, but only display them if a connection still exists
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], self, nil, nil, nil,
@@ -809,7 +809,7 @@
}
// Check for any errors, only displaying them if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], self, nil, nil, nil,
@@ -840,7 +840,7 @@
// this happens e.g. for db "information_schema"
if([[status objectForKey:@"Rows"] isKindOfClass:[NSNull class]]) {
tableStatusResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [escapedTableName backtickQuotedString] ]];
- if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""])
+ if (![mySQLConnection queryErrored])
[status setObject:[[tableStatusResult fetchRowAsArray] objectAtIndex:0] forKey:@"Rows"];
[status setObject:@"y" forKey:@"RowsCountAccurate"];
}
@@ -1064,7 +1064,7 @@
if([r numOfRows] < 1) return nil;
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected])
NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while retrieving the PRIAMRY KEY data:\n\n%@", [mySQLConnection getLastErrorMessage]], @"OK", nil, nil);
return nil;
diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m
index 3f79dbe7..34b18eae 100644
--- a/Source/SPTableRelations.m
+++ b/Source/SPTableRelations.m
@@ -132,11 +132,8 @@
// Execute query
[connection queryString:query];
-
- NSInteger retCode = (![[connection getLastErrorMessage] isEqualToString:@""]);
-
- // 0 indicates success
- if (retCode) {
+
+ if ([connection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error creating relation", @"error creating relation message"),
NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], nil, nil, nil, nil,
@@ -404,7 +401,7 @@
[connection queryString:query];
- if (![[connection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([connection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"),
NSLocalizedString(@"OK", @"OK button"),
diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m
index 78c9ba52..6e8d6873 100644
--- a/Source/SPTableTriggers.m
+++ b/Source/SPTableTriggers.m
@@ -128,10 +128,7 @@
// Execute query
[connection queryString:query];
- NSInteger retCode = (![[connection getLastErrorMessage] isEqualToString:@""]);
-
- // Zero indicates success
- if (retCode) {
+ if (([connection queryErrored])) {
SPBeginAlertSheet(NSLocalizedString(@"Error creating trigger", @"error creating trigger message"),
NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], nil, nil, nil, nil,
@@ -320,7 +317,7 @@
[connection queryString:query];
- if (![[connection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([connection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Unable to remove trigger", @"error removing trigger message"),
NSLocalizedString(@"OK", @"OK button"),
diff --git a/Source/SPUserManager.m b/Source/SPUserManager.m
index 35b4bcec..b3fbbc3f 100644
--- a/Source/SPUserManager.m
+++ b/Source/SPUserManager.m
@@ -1176,7 +1176,7 @@
*/
- (BOOL)checkAndDisplayMySqlError
{
- if (![[self.mySqlConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([self.mySqlConnection queryErrored]) {
NSAlert *alert = [NSAlert alertWithMessageText:@"MySQL Error"
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
diff --git a/Source/TableContent.m b/Source/TableContent.m
index 51d9cbe3..0e2d1d9b 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -640,7 +640,7 @@
}
}
- if ([mySQLConnection queryCancelled] || ![[mySQLConnection getLastErrorMessage] isEqualToString:@""])
+ if ([mySQLConnection queryCancelled] || [mySQLConnection queryErrored])
isInterruptedLoad = YES;
else
isInterruptedLoad = NO;
@@ -1898,7 +1898,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
// If no rows have been changed, show error if appropriate.
- if ( ![mySQLConnection affectedRows] && ![mySQLConnection getLastErrorMessage] && ![[mySQLConnection getLastErrorMessage] length]) {
+ if ( ![mySQLConnection affectedRows] && ![mySQLConnection queryErrored] ) {
if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) {
SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db"));
@@ -1913,7 +1913,7 @@
return YES;
// On success...
- } else if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ } else if ( ![mySQLConnection queryErrored] ) {
isEditingRow = NO;
// New row created successfully
@@ -2160,7 +2160,7 @@
} else if ( [contextInfo isEqualToString:@"removeallrows"] ) {
if ( returnCode == NSAlertDefaultReturn ) {
[mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@", [selectedTable backtickQuotedString]]];
- if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ( ![mySQLConnection queryErrored] ) {
// Reset auto increment if suppression button was ticked
if([[sheet suppressionButton] state] == NSOnState)
@@ -2205,7 +2205,7 @@
// Get the number of rows in the table
MCPResult *r;
r = [mySQLConnection queryString:[NSString stringWithFormat:@"SELECT COUNT(1) FROM %@", [selectedTable backtickQuotedString]]];
- if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if (![mySQLConnection queryErrored]) {
NSArray *a = [r fetchRowAsArray];
if([a count])
numberOfRows = [[a objectAtIndex:0] integerValue];
@@ -2231,7 +2231,7 @@
[mySQLConnection queryString:[NSString stringWithFormat:@"DELETE FROM %@ WHERE %@", [selectedTable backtickQuotedString], wherePart]];
// Check for errors
- if ( ![mySQLConnection affectedRows] || ![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ( ![mySQLConnection affectedRows] || [mySQLConnection queryErrored]) {
// If error delete that index from selectedRows for reloading table if
// "ReloadAfterRemovingRow" is disbaled
if(!reloadAfterRemovingRow)
@@ -2868,7 +2868,7 @@
previousTableRowsCount = tableRowsCount;
[self loadTableValues];
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"Couldn't sort table. MySQL said: %@", @"message of panel when sorting of table failed"), [mySQLConnection getLastErrorMessage]]);
[tableDocumentInstance endTask];
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 7e51de3c..949f2a68 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -1061,7 +1061,7 @@
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self];
MCPResult *theResult = [mySQLConnection queryString:@"SELECT DATABASE()"];
- if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if (![mySQLConnection queryErrored]) {
NSInteger i;
NSInteger r = [theResult numOfRows];
if (r) [theResult dataSeek:0];
@@ -1439,7 +1439,7 @@
// set encoding of connection and client
[mySQLConnection queryString:[NSString stringWithFormat:@"SET NAMES '%@'", mysqlEncoding]];
- if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if (![mySQLConnection queryErrored]) {
if (_encodingViaLatin1)
[mySQLConnection queryString:@"SET CHARACTER_SET_RESULTS=latin1"];
[mySQLConnection setEncoding:[MCPConnection encodingForMySQLEncoding:[mysqlEncoding UTF8String]]];
@@ -1448,7 +1448,7 @@
} else {
[mySQLConnection queryString:[NSString stringWithFormat:@"SET NAMES '%@'", [self databaseEncoding]]];
_encodingViaLatin1 = NO;
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
NSLog(@"Error: could not set encoding to %@ nor fall back to database encoding on MySQL %@", mysqlEncoding, [self mySQLVersion]);
return;
}
@@ -1656,7 +1656,7 @@
[theResult setReturnDataAsStrings:YES];
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while creating table syntax.\n\n: %@",[mySQLConnection getLastErrorMessage]], @"OK", nil, nil);
}
@@ -1715,7 +1715,7 @@
[theResult setReturnDataAsStrings:YES];
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
NSRunAlertPanel(@"Error", [NSString stringWithFormat:@"An error occured while creating table syntax.\n\n: %@",[mySQLConnection getLastErrorMessage]], @"OK", nil, nil);
}
@@ -1755,7 +1755,7 @@
NSString *what = ([selectedItems count]>1) ? NSLocalizedString(@"selected items", @"selected items") : [NSString stringWithFormat:@"%@ '%@'", NSLocalizedString(@"table", @"table"), [self table]];
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
NSString *mText = ([selectedItems count]>1) ? NSLocalizedString(@"Unable to check selected items", @"unable to check selected items message") : NSLocalizedString(@"Unable to check table", @"unable to check table message");
if ([mySQLConnection isConnected]) {
@@ -1831,7 +1831,7 @@
NSString *what = ([selectedItems count]>1) ? NSLocalizedString(@"selected items", @"selected items") : [NSString stringWithFormat:@"%@ '%@'", NSLocalizedString(@"table", @"table"), [self table]];
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
NSString *mText = ([selectedItems count]>1) ? NSLocalizedString(@"Unable to analyze selected items", @"unable to analyze selected items message") : NSLocalizedString(@"Unable to analyze table", @"unable to analyze table message");
if ([mySQLConnection isConnected]) {
@@ -1907,7 +1907,7 @@
NSString *what = ([selectedItems count]>1) ? NSLocalizedString(@"selected items", @"selected items") : [NSString stringWithFormat:@"%@ '%@'", NSLocalizedString(@"table", @"table"), [self table]];
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
NSString *mText = ([selectedItems count]>1) ? NSLocalizedString(@"Unable to optimze selected items", @"unable to optimze selected items message") : NSLocalizedString(@"Unable to optimze table", @"unable to optimze table message");
if ([mySQLConnection isConnected]) {
@@ -1982,7 +1982,7 @@
NSString *what = ([selectedItems count]>1) ? NSLocalizedString(@"selected items", @"selected items") : [NSString stringWithFormat:@"%@ '%@'", NSLocalizedString(@"table", @"table"), [self table]];
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
NSString *mText = ([selectedItems count]>1) ? NSLocalizedString(@"Unable to repair selected items", @"unable to repair selected items message") : NSLocalizedString(@"Unable to repair table", @"unable to repair table message");
if ([mySQLConnection isConnected]) {
@@ -2057,7 +2057,7 @@
NSString *what = ([selectedItems count]>1) ? NSLocalizedString(@"selected items", @"selected items") : [NSString stringWithFormat:@"%@ '%@'", NSLocalizedString(@"table", @"table"), [self table]];
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
NSString *mText = ([selectedItems count]>1) ? NSLocalizedString(@"Unable to flush selected items", @"unable to flush selected items message") : NSLocalizedString(@"Unable to flush table", @"unable to flush table message");
if ([mySQLConnection isConnected]) {
@@ -2132,7 +2132,7 @@
NSString *what = ([selectedItems count]>1) ? NSLocalizedString(@"selected items", @"selected items") : [NSString stringWithFormat:@"%@ '%@'", NSLocalizedString(@"table", @"table"), [self table]];
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
[[NSAlert alertWithMessageText:NSLocalizedString(@"Unable to perform the checksum", @"unable to perform the checksum")
@@ -2276,7 +2276,7 @@
// Before displaying the user manager make sure the current user has access to the mysql.user table.
MCPResult *result = [mySQLConnection queryString:@"SELECT * FROM `mysql`.`user` ORDER BY `user`"];
- if ((![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) && ([result numOfRows] == 0)) {
+ if ([mySQLConnection queryErrored] && ([result numOfRows] == 0)) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Unable to get list of users", @"unable to get list of users message")
defaultButton:NSLocalizedString(@"OK", @"OK button")
@@ -2323,7 +2323,7 @@
{
[mySQLConnection queryString:@"FLUSH PRIVILEGES"];
- if ( [[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if (![mySQLConnection queryErrored]) {
//flushed privileges without errors
SPBeginAlertSheet(NSLocalizedString(@"Flushed Privileges", @"title of panel when successfully flushed privs"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Successfully flushed privileges.", @"message of panel when successfully flushed privs"));
} else {
@@ -4041,7 +4041,7 @@
// Create the database
[mySQLConnection queryString:createStatement];
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
// An error occurred
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't create database.\nMySQL said: %@", @"message of panel when creation of db failed"), [mySQLConnection getLastErrorMessage]]);
@@ -4078,7 +4078,7 @@
// Drop the database from the server
[mySQLConnection queryString:[NSString stringWithFormat:@"DROP DATABASE %@", [[self database] backtickQuotedString]]];
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
// An error occurred
[self performSelector:@selector(showErrorSheetWith:)
withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"),
diff --git a/Source/TableDump.m b/Source/TableDump.m
index 26ed5e48..a86b5332 100644
--- a/Source/TableDump.m
+++ b/Source/TableDump.m
@@ -694,7 +694,7 @@
[mySQLConnection queryString:query usingEncoding:sqlEncoding streamingResult:NO];
// Check for any errors
- if ([[mySQLConnection getLastErrorMessage] length] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
+ if ([mySQLConnection queryErrored] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
[errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection getLastErrorMessage]]];
}
@@ -723,7 +723,7 @@
[mySQLConnection queryString:query usingEncoding:sqlEncoding streamingResult:NO];
// Check for any errors
- if ([[mySQLConnection getLastErrorMessage] length] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
+ if ([mySQLConnection queryErrored] && ![[mySQLConnection getLastErrorMessage] isEqualToString:@"Query was empty"]) {
[errors appendString:[NSString stringWithFormat:NSLocalizedString(@"[ERROR in query %ld] %@\n", @"error text when multiple custom query failed"), (long)(queriesPerformed+1), [mySQLConnection getLastErrorMessage]]];
}
@@ -1037,7 +1037,7 @@
[mySQLConnection queryString:query];
[query release];
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[tableDocumentInstance showConsole:nil];
[errors appendString:[NSString stringWithFormat:
NSLocalizedString(@"[ERROR in row %ld] %@\n", @"error text when reading of csv file gave errors"),
@@ -1055,7 +1055,7 @@
[mySQLConnection queryString:query];
[query release];
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[errors appendString:[NSString stringWithFormat:
NSLocalizedString(@"[ERROR in row %ld] %@\n", @"error text when reading of csv file gave errors"),
(long)(rowsImported+1),[mySQLConnection getLastErrorMessage]]];
@@ -1070,7 +1070,7 @@
}
}
// If an error occurred, run the queries individually to get exact line errors
- if (!importMethodIsUpdate && ![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if (!importMethodIsUpdate && [mySQLConnection queryErrored]) {
[tableDocumentInstance showConsole:nil];
for (i = 0; i < csvRowsThisQuery; i++) {
if (progressCancelled) break;
@@ -1084,7 +1084,7 @@
[mySQLConnection queryString:query];
[query release];
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[errors appendString:[NSString stringWithFormat:
NSLocalizedString(@"[ERROR in row %ld] %@\n", @"error text when reading of csv file gave errors"),
(long)(rowsImported+1),[mySQLConnection getLastErrorMessage]]];
@@ -1574,7 +1574,7 @@
}
[tableDetails release];
}
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[errors appendString:[NSString stringWithFormat:@"%@\n", [mySQLConnection getLastErrorMessage]]];
if ( [addErrorsSwitch state] == NSOnState ) {
[fileHandle writeData:[[NSString stringWithFormat:@"# Error: %@\n", [mySQLConnection getLastErrorMessage]] dataUsingEncoding:NSUTF8StringEncoding]];
@@ -1735,7 +1735,7 @@
[exportAutoReleasePool drain];
}
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[errors appendString:[NSString stringWithFormat:@"%@\n", [mySQLConnection getLastErrorMessage]]];
if ( [addErrorsSwitch state] == NSOnState ) {
[fileHandle writeData:[[NSString stringWithFormat:@"# Error: %@\n", [mySQLConnection getLastErrorMessage]]
@@ -1783,7 +1783,7 @@
[fileHandle writeData:[metaString dataUsingEncoding:NSUTF8StringEncoding]];
}
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[errors appendString:[NSString stringWithFormat:@"%@\n", [mySQLConnection getLastErrorMessage]]];
if ( [addErrorsSwitch state] == NSOnState ) {
[fileHandle writeData:[[NSString stringWithFormat:@"# Error: %@\n", [mySQLConnection getLastErrorMessage]]
@@ -1893,7 +1893,7 @@
[fileHandle writeData:[metaString dataUsingEncoding:NSUTF8StringEncoding]];
}
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[errors appendString:[NSString stringWithFormat:@"%@\n", [mySQLConnection getLastErrorMessage]]];
if ( [addErrorsSwitch state] == NSOnState ) {
[fileHandle writeData:[[NSString stringWithFormat:@"# Error: %@\n", [mySQLConnection getLastErrorMessage]]
@@ -2650,7 +2650,7 @@
streamingResult = [[mySQLConnection streamingQueryString:[NSString stringWithFormat:@"SELECT * FROM %@", [tableName backtickQuotedString]] useLowMemoryBlockingStreaming:useLowMemoryBlockingStreaming] retain];
// Note any errors during initial query
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[errors appendString:[NSString stringWithFormat:@"%@\n", [mySQLConnection getLastErrorMessage]]];
}
@@ -2705,7 +2705,7 @@
[streamingResult release];
// Note any errors during data retrieval
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
[errors appendString:[NSString stringWithFormat:@"%@\n", [mySQLConnection getLastErrorMessage]]];
}
}
diff --git a/Source/TableSource.m b/Source/TableSource.m
index 38a6b16d..0358f821 100644
--- a/Source/TableSource.m
+++ b/Source/TableSource.m
@@ -74,7 +74,7 @@
tableSourceResult = [[mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [aTable backtickQuotedString]]] retain];
// If an error occurred, reset the interface and abort
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
NSString *errorMessage = [NSString stringWithString:[mySQLConnection getLastErrorMessage]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
@@ -96,7 +96,7 @@
indexResult = [[mySQLConnection queryString:[NSString stringWithFormat:@"SHOW INDEX FROM %@", [aTable backtickQuotedString]]] retain];
// If an error occurred, reset the interface and abort
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
NSString *errorMessage = [NSString stringWithString:[mySQLConnection getLastErrorMessage]];
[[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance];
@@ -579,7 +579,7 @@ closes the keySheet
[mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ AUTO_INCREMENT = %@", [selTable backtickQuotedString], valueAsString]];
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"),
NSLocalizedString(@"OK", @"OK button"),
nil, nil, [NSApp mainWindow], nil, nil, nil, nil,
@@ -846,7 +846,7 @@ closes the keySheet
// Execute query
[mySQLConnection queryString:queryString];
- if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if (![mySQLConnection queryErrored]) {
isEditingRow = NO;
isEditingNewRow = NO;
currentlyEditingRow = -1;
@@ -1442,7 +1442,7 @@ would result in a position change.
// Run the query; report any errors, or reload the table on success
[mySQLConnection queryString:queryString];
- if ( ![[mySQLConnection getLastErrorMessage] isEqualTo:@""] ) {
+ if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"Couldn't move field. MySQL said: %@", @"message of panel when field cannot be added in drag&drop operation"), [mySQLConnection getLastErrorMessage]]);
} else {
@@ -1699,7 +1699,7 @@ would result in a position change.
[tempIndexedColumns componentsJoinedAndBacktickQuoted]]];
// Check for errors, but only if the query wasn't cancelled
- if ((![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) && (![mySQLConnection queryCancelled])) {
+ if ([mySQLConnection queryErrored] && ![mySQLConnection queryCancelled]) {
SPBeginAlertSheet(NSLocalizedString(@"Unable to add index", @"add index error message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"An error occured while trying to add the index.\n\nMySQL said: %@", @"add index error informative message"), [mySQLConnection getLastErrorMessage]]);
}
@@ -1745,7 +1745,7 @@ would result in a position change.
[mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ DROP FOREIGN KEY %@", [selectedTable backtickQuotedString], [relationName backtickQuotedString]]];
// Check for errors, but only if the query wasn't cancelled
- if ((![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) && (![mySQLConnection queryCancelled])) {
+ if ([mySQLConnection queryErrored] && ![mySQLConnection queryCancelled]) {
SPBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"),
NSLocalizedString(@"OK", @"OK button"),
@@ -1759,7 +1759,7 @@ would result in a position change.
[selectedTable backtickQuotedString], [[[tableFields objectAtIndex:[tableSourceView selectedRow]] objectForKey:@"Field"] backtickQuotedString]]];
// Check for errors, but only if the query wasn't cancelled
- if ((![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) && (![mySQLConnection queryCancelled])) {
+ if ([mySQLConnection queryErrored] && ![mySQLConnection queryCancelled]) {
[self performSelector:@selector(showErrorSheetWith:)
withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Error", @"error"),
@@ -1813,7 +1813,7 @@ would result in a position change.
[mySQLConnection queryString:[NSString stringWithFormat:@"ALTER TABLE %@ DROP FOREIGN KEY %@", [selectedTable backtickQuotedString], [constraintName backtickQuotedString]]];
// Check for errors, but only if the query wasn't cancelled
- if ((![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) && (![mySQLConnection queryCancelled])) {
+ if ([mySQLConnection queryErrored] && ![mySQLConnection queryCancelled]) {
SPBeginAlertSheet(NSLocalizedString(@"Unable to remove relation", @"error removing relation message"),
NSLocalizedString(@"OK", @"OK button"),
@@ -1831,7 +1831,7 @@ would result in a position change.
}
// Check for errors, but only if the query wasn't cancelled
- if ((![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) && (![mySQLConnection queryCancelled])) {
+ if ([mySQLConnection queryErrored] && ![mySQLConnection queryCancelled]) {
[self performSelector:@selector(showErrorSheetWith:)
withObject:[NSArray arrayWithObjects:NSLocalizedString(@"Unable to remove index", @"error removing index message"),
diff --git a/Source/TablesList.m b/Source/TablesList.m
index 21ea8078..76e653be 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -130,7 +130,7 @@
// Check for mysql errors - if information_schema is not accessible for some reasons
// omit adding procedures and functions
- if([[mySQLConnection getLastErrorMessage] isEqualToString:@""] && theResult != nil && [theResult numOfRows] ) {
+ if(![mySQLConnection queryErrored] && theResult != nil && [theResult numOfRows] ) {
// add the header row
[tables addObject:NSLocalizedString(@"PROCS & FUNCS",@"header for procs & funcs list")];
[tableTypes addObject:[NSNumber numberWithInteger:SPTableTypeNone]];
@@ -1863,7 +1863,7 @@
}
// If no error is recorded, the table was successfully dropped - remove it from the list
- if ([[mySQLConnection getLastErrorMessage] isEqualTo:@""]) {
+ if (![mySQLConnection queryErrored]) {
//dropped table with success
if (isTableListFiltered) {
NSInteger unfilteredIndex = [tables indexOfObject:[filteredTables objectAtIndex:currentIndex]];
@@ -1939,7 +1939,7 @@
[mySQLConnection queryString:[NSString stringWithFormat: @"TRUNCATE TABLE %@", [[filteredTables objectAtIndex:currentIndex] backtickQuotedString]]];
// Couldn't truncate table
- if (![[mySQLConnection getLastErrorMessage] isEqualTo:@""]) {
+ if ([mySQLConnection queryErrored]) {
NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"Error truncating table", @"error truncating table message")
defaultButton:NSLocalizedString(@"OK", @"OK button")
alternateButton:nil
@@ -1987,7 +1987,7 @@
// Create the table
[mySQLConnection queryString:createStatement];
- if ([[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if (![mySQLConnection queryErrored]) {
// Table creation was successful - insert the new item into the tables list and select it.
NSInteger addItemAtIndex = NSNotFound;
@@ -2127,7 +2127,7 @@
return;
// Check for errors, only displaying if the connection hasn't been terminated
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
if ([mySQLConnection isConnected]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"An error occured while retrieving the create syntax for '%@'.\nMySQL said: %@", @"message of panel when create syntax cannot be retrieved"), selectedTableName, [mySQLConnection getLastErrorMessage]]);
@@ -2141,14 +2141,14 @@
// replace the old name by the new one and drop the old one
[mySQLConnection queryString:[tableSyntax stringByReplacingOccurrencesOfRegex:[NSString stringWithFormat:@"(?<=%@ )(`[^`]+?`)", [tableType uppercaseString]] withString:[[copyTableNameField stringValue] backtickQuotedString]]];
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"Couldn't duplicate '%@'.\nMySQL said: %@", @"message of panel when an item cannot be renamed"), [copyTableNameField stringValue], [mySQLConnection getLastErrorMessage]]);
}
}
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
//error while creating new table
SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil,
[NSString stringWithFormat:NSLocalizedString(@"Couldn't create '%@'.\nMySQL said: %@", @"message of panel when table cannot be created"), [copyTableNameField stringValue], [mySQLConnection getLastErrorMessage]]);
@@ -2162,7 +2162,7 @@
[selectedTableName backtickQuotedString]
]];
- if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) {
+ if ([mySQLConnection queryErrored]) {
SPBeginAlertSheet(
NSLocalizedString(@"Warning", @"warning"),
NSLocalizedString(@"OK", @"OK button"),
@@ -2256,7 +2256,7 @@
// we can use the rename table statement
[mySQLConnection queryString:[NSString stringWithFormat:@"RENAME TABLE %@ TO %@", [oldTableName backtickQuotedString], [newTableName backtickQuotedString]]];
// check for errors
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
[NSException raise:@"MySQL Error" format:NSLocalizedString(@"An error occured while renaming '%@'.\n\nMySQL said: %@", @"rename table error informative message"), oldTableName, [mySQLConnection getLastErrorMessage]];
}
return;
@@ -2275,7 +2275,7 @@
}
MCPResult *theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW CREATE %@ %@", stringTableType, [oldTableName backtickQuotedString] ] ];
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
[NSException raise:@"MySQL Error" format:NSLocalizedString(@"An error occured while renaming. I couldn't retrieve the syntax for '%@'.\n\nMySQL said: %@", @"rename precedure/function error - can't retrieve syntax"), oldTableName, [mySQLConnection getLastErrorMessage]];
}
[theResult setReturnDataAsStrings:YES];
@@ -2289,12 +2289,12 @@
NSString *newCreateSyntax = [oldCreateSyntax stringByReplacingCharactersInRange: rangeOfProcedureName
withString: [NSString stringWithFormat:@"%@ %@", stringTableType, [newTableName backtickQuotedString] ] ];
[mySQLConnection queryString: newCreateSyntax];
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
[NSException raise:@"MySQL Error" format:NSLocalizedString(@"An error occured while renaming. I couldn't recreate '%@'.\n\nMySQL said: %@", @"rename precedure/function error - can't recreate procedure"), oldTableName, [mySQLConnection getLastErrorMessage]];
}
[mySQLConnection queryString: [NSString stringWithFormat: @"DROP %@ %@", stringTableType, [oldTableName backtickQuotedString]]];
- if (![[mySQLConnection getLastErrorMessage] isEqualToString:@""]) {
+ if ([mySQLConnection queryErrored]) {
[NSException raise:@"MySQL Error" format:NSLocalizedString(@"An error occured while renaming. I couldn't remove '%@'.\n\nMySQL said: %@", @"rename precedure/function error - can't remove old procedure"), oldTableName, [mySQLConnection getLastErrorMessage]];
}
return;