diff options
author | rowanbeentje <rowan@beent.je> | 2010-03-31 00:34:03 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2010-03-31 00:34:03 +0000 |
commit | b9f5c468900eca5748392d61a603b425492706f6 (patch) | |
tree | bee5f4c2ca46d39ec2e76972f089fba9e802be15 /Source/SPTableData.m | |
parent | d060c9f395f938d1d1adeec0ce8a9444267bdebf (diff) | |
download | sequelpro-b9f5c468900eca5748392d61a603b425492706f6.tar.gz sequelpro-b9f5c468900eca5748392d61a603b425492706f6.tar.bz2 sequelpro-b9f5c468900eca5748392d61a603b425492706f6.zip |
- Improve error checking for various actions, particularly permissions errors (NULL data returned) for views and stored procedures. This should fix http://log.sequelpro.com/view/27 , http://log.sequelpro.com/view/57 , and the last of http://log.sequelpro.com/view/53
Diffstat (limited to 'Source/SPTableData.m')
-rw-r--r-- | Source/SPTableData.m | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/Source/SPTableData.m b/Source/SPTableData.m index b75f6dd5..7021ddc2 100644 --- a/Source/SPTableData.m +++ b/Source/SPTableData.m @@ -93,7 +93,10 @@ [self updateInformationForCurrentTable]; } } - + + // On failure, return nil + if (!tableCreateSyntax) return nil; + return [NSString stringWithString:tableCreateSyntax]; } @@ -354,8 +357,19 @@ // connection reconnect dialog to appear and the user chose to close the connection. if (!syntaxResult) return nil; - if (tableCreateSyntax != nil) [tableCreateSyntax release]; - + if (tableCreateSyntax != nil) [tableCreateSyntax release], tableCreateSyntax = nil; + + // A NULL value indicates that the user does not have permission to view the syntax + if ([[syntaxResult objectAtIndex:1] isNSNull]) { + [[NSAlert alertWithMessageText:NSLocalizedString(@"Permission Denied", @"Permission Denied") + defaultButton:NSLocalizedString(@"OK", @"OK") + alternateButton:nil otherButton:nil + informativeTextWithFormat:NSLocalizedString(@"The creation syntax could not be retrieved due to a permissions error.\n\nPlease check your user permissions with an administrator.", @"Create syntax permission denied detail")] + beginSheetModalForWindow:[NSApp mainWindow] + modalDelegate:self didEndSelector:NULL contextInfo:NULL]; + return nil; + } + tableCreateSyntax = [[NSString alloc] initWithString:[syntaxResult objectAtIndex:1]]; createTableParser = [[SPSQLParser alloc] initWithString:[syntaxResult objectAtIndex:1]]; @@ -708,7 +722,20 @@ // Retrieve the table syntax string if (tableCreateSyntax) [tableCreateSyntax release], tableCreateSyntax = nil; - tableCreateSyntax = [[NSString alloc] initWithString:[[theResult fetchRowAsArray] objectAtIndex:1]]; + NSString *syntaxString = [[theResult fetchRowAsArray] objectAtIndex:1]; + + // A NULL value indicates that the user does not have permission to view the syntax + if ([syntaxString isNSNull]) { + [[NSAlert alertWithMessageText:NSLocalizedString(@"Permission Denied", @"Permission Denied") + defaultButton:NSLocalizedString(@"OK", @"OK") + alternateButton:nil otherButton:nil + informativeTextWithFormat:NSLocalizedString(@"The creation syntax could not be retrieved due to a permissions error.\n\nPlease check your user permissions with an administrator.", @"Create syntax permission denied detail")] + beginSheetModalForWindow:[NSApp mainWindow] + modalDelegate:self didEndSelector:NULL contextInfo:NULL]; + return nil; + } + + tableCreateSyntax = [[NSString alloc] initWithString:syntaxString]; // Retrieve the SHOW COLUMNS syntax for the table theResult = [mySQLConnection queryString:[NSString stringWithFormat:@"SHOW COLUMNS FROM %@", [viewName backtickQuotedString]]]; |