diff --git a/Sources/PerfectMySQL/MySQL.swift b/Sources/PerfectMySQL/MySQL.swift index 429803b..59d0ba1 100644 --- a/Sources/PerfectMySQL/MySQL.swift +++ b/Sources/PerfectMySQL/MySQL.swift @@ -97,7 +97,12 @@ public final class MySQL { } return result } - + + /// If false it starts transaction which can be rolled back + public func autocommit(_ autocommit: Bool) -> Bool { + return mysql_autocommit(mysqlPtr, autocommit) + } + /// Commits the transaction public func commit() -> Bool { var res = mysql_commit(mysqlPtr) @@ -248,7 +253,7 @@ public final class MySQL { /// Sets connect options for connect() with boolean option argument @discardableResult public func setOption(_ option: MySQLOpt, _ b: Bool) -> Bool { - var myB = my_bool(b ? 1 : 0) + var myB = false ? 1 : 0 return mysql_options(mysqlPtr, exposedOptionToMySQLOption(option), &myB) == 0 } diff --git a/Sources/PerfectMySQL/MySQLCRUD.swift b/Sources/PerfectMySQL/MySQLCRUD.swift index a81e884..c4716b5 100644 --- a/Sources/PerfectMySQL/MySQLCRUD.swift +++ b/Sources/PerfectMySQL/MySQLCRUD.swift @@ -515,7 +515,7 @@ public struct MySQLDatabaseConfiguration: DatabaseConfigurationProtocol { } public func sqlExeDelegate(forSQL: String) throws -> SQLExeDelegate { - let noPrepCommands = ["CREATE", "DROP", "ALTER", "BEGIN", "COMMIT", "ROLLBACK"] + let noPrepCommands = ["CREATE", "DROP", "ALTER", "BEGIN", "COMMIT", "ROLLBACK", "LOCK", "UNLOCK"] if nil != noPrepCommands.first(where: { forSQL.hasPrefix($0) }) { return MySQLDirectExeDelegate(connection: connection, sql: forSQL) } diff --git a/Sources/PerfectMySQL/MySQLStmt.swift b/Sources/PerfectMySQL/MySQLStmt.swift index 67af670..8ca51f0 100644 --- a/Sources/PerfectMySQL/MySQLStmt.swift +++ b/Sources/PerfectMySQL/MySQLStmt.swift @@ -294,9 +294,13 @@ public final class MySQLStmt { private func allocated(_ a: [Int8]) -> UnsafeMutableRawBufferPointer? { let buffer = UnsafeMutableRawBufferPointer.allocate(byteCount: a.count, alignment: 0) - let u = UnsafeRawPointer(a) - if let p = buffer.baseAddress { - memcpy(p, u, a.count) + a.withUnsafeBytes{ (bufferRawBufferPointer) -> Void in + let bufferPointer: UnsafePointer = bufferRawBufferPointer.baseAddress!.assumingMemoryBound(to: UInt8.self) + let rawPtr = UnsafeRawPointer(bufferPointer) + //let u = UnsafeRawPointer(a) + if let p = buffer.baseAddress { + memcpy(p, rawPtr, a.count) + } } return buffer }