Skip to content

Commit 33babf7

Browse files
committed
added server options
1 parent e5e1b40 commit 33babf7

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Sources/PerfectMySQL/MySQL.swift

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,17 @@ public final class MySQL {
217217
return MYSQL_ENABLE_CLEARTEXT_PLUGIN
218218
case MySQLOpt.MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS:
219219
return MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
220-
}
221-
}
220+
}
221+
}
222+
223+
func exposedOptionToMySQLServerOption(_ o: MySQLServerOpt) -> enum_mysql_set_option {
224+
switch o {
225+
case MySQLServerOpt.MYSQL_OPTION_MULTI_STATEMENTS_ON:
226+
return MYSQL_OPTION_MULTI_STATEMENTS_ON
227+
case MySQLServerOpt.MYSQL_OPTION_MULTI_STATEMENTS_OFF:
228+
return MYSQL_OPTION_MULTI_STATEMENTS_OFF
229+
}
230+
}
222231

223232
/// Sets connect options for connect()
224233
@discardableResult
@@ -249,6 +258,12 @@ public final class MySQL {
249258
}
250259
return b
251260
}
261+
262+
/// Sets connect options after connect()
263+
@discardableResult
264+
public func setServerOption(_ option: MySQLServerOpt) -> Bool {
265+
return mysql_set_server_option(mysqlPtr, exposedOptionToMySQLServerOption(option)) == 0
266+
}
252267

253268
/// Class used to manage and interact with result sets
254269
public final class Results: IteratorProtocol {

Sources/PerfectMySQL/PerfectMySQL.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,8 @@ public enum MySQLOpt {
111111
MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS
112112
}
113113

114+
/// enum for mysql options
115+
public enum MySQLServerOpt {
116+
case MYSQL_OPTION_MULTI_STATEMENTS_ON, MYSQL_OPTION_MULTI_STATEMENTS_OFF
117+
}
114118

0 commit comments

Comments
 (0)