aboutsummaryrefslogtreecommitdiffstats
path: root/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories
diff options
context:
space:
mode:
authorMax <post@wickenrode.com>2015-11-12 01:42:02 +0100
committerMax <post@wickenrode.com>2015-11-12 01:42:02 +0100
commit0dbadf887635bb3904d3aa64a0588a0b23d884dc (patch)
tree34288e2ff62716e7f702692e8985f3a7f5a47678 /Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories
parentafd6f72c968547a0b228b02780409d8f01096da5 (diff)
downloadsequelpro-0dbadf887635bb3904d3aa64a0588a0b23d884dc.tar.gz
sequelpro-0dbadf887635bb3904d3aa64a0588a0b23d884dc.tar.bz2
sequelpro-0dbadf887635bb3904d3aa64a0588a0b23d884dc.zip
In order to enable even more people to shoot themselves in the foot, this commit adds support for remote server shutdown
💣
Diffstat (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories')
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.h7
-rw-r--r--Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m17
2 files changed, 24 insertions, 0 deletions
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.h b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.h
index 82607cdb..844a6b5f 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.h
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.h
@@ -45,4 +45,11 @@
- (SPMySQLResult *)listProcesses;
- (BOOL)killQueryOnThreadID:(unsigned long)theThreadID;
+/**
+ * mysql_shutdown() - If the user has the permission, will shutdown the (remote) server
+ * @return Whether the command was executed successfully
+ * Note: this can also be NO if the user denied a reconnect attempt.
+ */
+- (BOOL)serverShutdown;
+
@end
diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m
index 5925d138..f9949121 100644
--- a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m
+++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Server Info.m
@@ -148,4 +148,21 @@
return ![self queryErrored];
}
+- (BOOL)serverShutdown
+{
+ if([self _checkConnectionIfNecessary]) {
+ [self _lockConnection];
+ // Ensure per-thread variables are set up
+ [self _validateThreadSetup];
+ //only SHUTDOWN_DEFAULT is supported right now
+ int res = mysql_shutdown(mySQLConnection, SHUTDOWN_DEFAULT);
+ //update or clear error
+ [self _updateLastErrorInfos];
+ [self _unlockConnection];
+
+ return (res == 0);
+ }
+ return NO;
+}
+
@end