diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPFileHandle.m | 11 | ||||
-rw-r--r-- | Source/SPTableCopy.m | 14 |
2 files changed, 18 insertions, 7 deletions
diff --git a/Source/SPFileHandle.m b/Source/SPFileHandle.m index 2f822c48..58350443 100644 --- a/Source/SPFileHandle.m +++ b/Source/SPFileHandle.m @@ -90,7 +90,7 @@ if (fileMode == O_RDONLY) { int i, c; - char *bzbuf = malloc(4); + char bzbuf[4]; const char *charFileMode = fileMode == O_WRONLY ? "wb" : "rb"; BZFILE *bzfile; @@ -112,12 +112,9 @@ // indicate the Bzip version. Finally, the 4th byte should be a number between 1 and 9 that indicates // the block size used. - BOOL isBzip2 = (sizeof(bzbuf) == 4) && - ((bzbuf[0] == 'B') && (bzbuf[1] == 'Z') && - ((bzbuf[2] == 'h') || (bzbuf[2] == '0')) && - ((bzbuf[3] >= 0x31) && (bzbuf[3] <= 0x39))); - - free(bzbuf); + BOOL isBzip2 = ((bzbuf[0] == 'B') && (bzbuf[1] == 'Z')) && + ((bzbuf[2] == 'h') || (bzbuf[2] == '0')) && + ((bzbuf[3] >= 0x31) && (bzbuf[3] <= 0x39)); if (isBzip2) bzfile = BZ2_bzopen(path, charFileMode); diff --git a/Source/SPTableCopy.m b/Source/SPTableCopy.m index bc2474ba..cd3fc42e 100644 --- a/Source/SPTableCopy.m +++ b/Source/SPTableCopy.m @@ -98,6 +98,13 @@ success = NO; } + // Disable auto-id creation for '0' values + [connection queryString:@"/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */"]; + + if([connection queryErrored]) { + success = NO; + } + for (NSString *tableName in tablesArray) { if (![self copyTable:tableName from:sourceDB to:targetDB withContent:copyWithContent]) { @@ -112,6 +119,13 @@ success = NO; } + // re-enable id creation + [connection queryString:@"/*!40101 SET SQL_MODE=@OLD_SQL_MODE */"]; + + if ([connection queryErrored]) { + success = NO; + } + return success; } |