aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/CMMCPConnection.h2
-rw-r--r--Source/CMMCPConnection.m34
-rw-r--r--Source/TableContent.m22
-rw-r--r--Source/TablesList.m1
4 files changed, 39 insertions, 20 deletions
diff --git a/Source/CMMCPConnection.h b/Source/CMMCPConnection.h
index 2a24aea8..f9b8b022 100644
--- a/Source/CMMCPConnection.h
+++ b/Source/CMMCPConnection.h
@@ -97,7 +97,7 @@
- (const char *) cStringFromString:(NSString *) theString usingEncoding:(NSStringEncoding) encoding;
- (int) getMaxAllowedPacket;
- (BOOL) isMaxAllowedPacketEditable;
-- (int) setMaxAllowedPacketTo:(int)newSize;
+- (int) setMaxAllowedPacketTo:(int)newSize resetSize:(BOOL)reset;
/* return server major version number or -1 on fail */
- (int)serverMajorVersion;
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index ca86fbd7..8b256cc4 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -655,14 +655,14 @@ static void forcePingTimeout(int signalNumber);
*/
- (CMMCPResult *)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding
{
- CMMCPResult *theResult = nil;
- NSDate *queryStartDate;
- const char *theCQuery;
- int queryResultCode;
- int currentMaxAllowedPacket = -1;
- unsigned int queryErrorID = 0;
- NSString *queryErrorMessage;
- unsigned long threadid = mConnection->thread_id;
+ CMMCPResult *theResult = nil;
+ NSDate *queryStartDate;
+ NSString *queryErrorMessage;
+ const char *theCQuery;
+ int queryResultCode;
+ int currentMaxAllowedPacket = -1;
+ unsigned int queryErrorID = 0;
+ unsigned long threadid = mConnection->thread_id;
// If no connection is present, return nil.
if (!mConnected) return nil;
@@ -693,10 +693,11 @@ static void forcePingTimeout(int signalNumber);
if (![self checkConnection]) return nil;
threadid = mConnection->thread_id;
- // Try to increase max_allowed_packet for error 2006 BEFORE check connection
+ // Try to increase max_allowed_packet for error 2006 if user
+ // has SUPER privileges
if(isMaxAllowedPacketEditable && queryResultCode == 1 && queryErrorID == 2006) {
currentMaxAllowedPacket = [self getMaxAllowedPacket];
- [self setMaxAllowedPacketTo:strlen(theCQuery)+1024];
+ [self setMaxAllowedPacketTo:strlen(theCQuery)+1024 resetSize:NO];
[self reconnect];
}
@@ -721,7 +722,7 @@ static void forcePingTimeout(int signalNumber);
// If max_allowed_packet was changed, reset it to default
if(currentMaxAllowedPacket > -1)
- [self setMaxAllowedPacketTo:currentMaxAllowedPacket];
+ [self setMaxAllowedPacketTo:currentMaxAllowedPacket resetSize:YES];
// If an error occurred, inform the delegate
if (0 != queryResultCode && delegate && [delegate respondsToSelector:@selector(queryGaveError:)]) {
@@ -1070,13 +1071,18 @@ static void forcePingTimeout(int signalNumber)
* if the maximal size was reached (e.g. set it to 4GB it'll return 1GB up to now).
* If something failed it return -1;
*/
-- (int) setMaxAllowedPacketTo:(int)newSize
+- (int) setMaxAllowedPacketTo:(int)newSize resetSize:(BOOL)reset
{
if(![self isMaxAllowedPacketEditable] || newSize < 1024) return [self getMaxAllowedPacket];
mysql_query(mConnection, [[NSString stringWithFormat:@"SET GLOBAL max_allowed_packet = %d", newSize] UTF8String]);
- // Inform the user via a log entry about that change
- [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %d for the current session to allow query to succeed", newSize]];
+ // Inform the user via a log entry about that change according to reset value
+ if(delegate && [delegate respondsToSelector:@selector(queryGaveError:)])
+ if(reset)
+ [delegate queryGaveError:[NSString stringWithFormat:@"max_allowed_packet was reset to %d for new session", newSize]];
+ else
+ [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %d for the current session to allow query to succeed", newSize]];
+
return [self getMaxAllowedPacket];
}
diff --git a/Source/TableContent.m b/Source/TableContent.m
index bb37b444..dd4f0981 100644
--- a/Source/TableContent.m
+++ b/Source/TableContent.m
@@ -1470,11 +1470,13 @@
return YES;
}
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryWillBePerformed" object:self];
// If editing, compare the new row to the old row and if they are identical finish editing without saving.
if (!isEditingNewRow && [oldRow isEqualToDictionary:[filteredResult objectAtIndex:currentlyEditingRow]]) {
isEditingRow = NO;
currentlyEditingRow = -1;
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self];
return YES;
}
@@ -1550,6 +1552,7 @@
isEditingNewRow = NO;
currentlyEditingRow = -1;
[[SPQueryConsole sharedQueryConsole] showErrorInConsole:[NSString stringWithFormat:NSLocalizedString(@"/* WARNING %@ No rows have been affected */\n", @"warning shown in the console when no rows have been affected after writing to the db"), currentTime]];
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self];
return YES;
// On success...
@@ -1603,12 +1606,16 @@
}
}
currentlyEditingRow = -1;
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self];
+
return YES;
// Report errors which have occurred
} else {
NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, @selector(sheetDidEnd:returnCode:contextInfo:), nil, @"addrow",
[NSString stringWithFormat:NSLocalizedString(@"Couldn't write row.\nMySQL said: %@", @"message of panel when error while adding row to db"), [mySQLConnection getLastErrorMessage]]);
+
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:self];
return NO;
}
}
@@ -2254,28 +2261,31 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
NSImage *image = nil;
editData = [theValue retain];
- // hide all view in editSheet
+ // hide all views in editSheet
[hexTextView setHidden:YES];
[hexTextScrollView setHidden:YES];
[editImage setHidden:YES];
[editTextView setHidden:YES];
[editTextScrollView setHidden:YES];
+ // Hide QuickLook button and text/iamge/hex control for text data
[editSheetQuickLookButton setHidden:(!isBlob)];
[editSheetSegmentControl setHidden:(!isBlob)];
- // order out editSheet to inform the user that
- // SP is working
+ // order out editSheet to inform the user that SP is working
[NSApp beginSheet:editSheet modalForWindow:tableWindow modalDelegate:self didEndSelector:nil contextInfo:nil];
[editSheetProgressBar startAnimation:self];
if ( [theValue isKindOfClass:[NSData class]] ) {
image = [[[NSImage alloc] initWithData:theValue] autorelease];
+
[hexTextView setString:[self dataToHex:theValue]];
+
stringValue = [[NSString alloc] initWithData:theValue encoding:[mySQLConnection encoding]];
if (stringValue == nil)
stringValue = [[NSString alloc] initWithData:theValue encoding:NSASCIIStringEncoding];
+
[hexTextView setHidden:NO];
[hexTextScrollView setHidden:NO];
[editImage setHidden:YES];
@@ -2283,9 +2293,10 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
[editTextScrollView setHidden:YES];
[editSheetSegmentControl setSelectedSegment:2];
} else {
- [hexTextView setString:@""];
- // stringValue = [[NSString alloc] initWithString:[theValue description]];
stringValue = [theValue retain];
+
+ [hexTextView setString:@""];
+
[hexTextView setHidden:YES];
[hexTextScrollView setHidden:YES];
[editImage setHidden:YES];
@@ -2296,6 +2307,7 @@ objectValueForTableColumn:(NSTableColumn *)aTableColumn
if (image) {
[editImage setImage:image];
+
[hexTextView setHidden:YES];
[hexTextScrollView setHidden:YES];
[editImage setHidden:NO];
diff --git a/Source/TablesList.m b/Source/TablesList.m
index 98b67904..1cd8d8de 100644
--- a/Source/TablesList.m
+++ b/Source/TablesList.m
@@ -812,6 +812,7 @@
// Get next index (beginning from the end)
currentIndex = [indexes indexLessThanIndex:currentIndex];
}
+ [tableContentInstance reloadTable:self];
}
/**