From ba9a70ebb03e0738458b0d8da658a1ab67fcc0ba Mon Sep 17 00:00:00 2001 From: SkOODaT <8633932+SkOODaT@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:02:54 -0400 Subject: [PATCH 1/4] Added missing autocommit call --- Sources/PerfectMySQL/MySQL.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/PerfectMySQL/MySQL.swift b/Sources/PerfectMySQL/MySQL.swift index 429803b..0377f9e 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 1 == mysql_autocommit(mysqlPtr, autocommit ? 1 : 0) + } + /// Commits the transaction public func commit() -> Bool { var res = mysql_commit(mysqlPtr) From 4af3f16fde00ef47fa5933bf064239d3cba8d81b Mon Sep 17 00:00:00 2001 From: SkOODaT <8633932+SkOODaT@users.noreply.github.com> Date: Mon, 21 Mar 2022 15:28:44 -0400 Subject: [PATCH 2/4] Update MySQL.swift --- Sources/PerfectMySQL/MySQL.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/PerfectMySQL/MySQL.swift b/Sources/PerfectMySQL/MySQL.swift index 0377f9e..05aae03 100644 --- a/Sources/PerfectMySQL/MySQL.swift +++ b/Sources/PerfectMySQL/MySQL.swift @@ -100,7 +100,7 @@ public final class MySQL { /// If false it starts transaction which can be rolled back public func autocommit(_ autocommit: Bool) -> Bool { - return 1 == mysql_autocommit(mysqlPtr, autocommit ? 1 : 0) + return mysql_autocommit(mysqlPtr, autocommit) } /// Commits the transaction From 76ed9da45fbbadc7a0fb5cf6b9cfd17ca4f752f0 Mon Sep 17 00:00:00 2001 From: SkOODaT <8633932+SkOODaT@users.noreply.github.com> Date: Mon, 21 Mar 2022 15:29:07 -0400 Subject: [PATCH 3/4] Fix Warnings --- Sources/PerfectMySQL/MySQL.swift | 2 +- Sources/PerfectMySQL/MySQLStmt.swift | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Sources/PerfectMySQL/MySQL.swift b/Sources/PerfectMySQL/MySQL.swift index 05aae03..59d0ba1 100644 --- a/Sources/PerfectMySQL/MySQL.swift +++ b/Sources/PerfectMySQL/MySQL.swift @@ -253,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/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 } From 8248d36532e9ca1bbfae4ec0b4849125cc095551 Mon Sep 17 00:00:00 2001 From: SkOODaT <8633932+SkOODaT@users.noreply.github.com> Date: Mon, 21 Mar 2022 17:20:20 -0400 Subject: [PATCH 4/4] Update MySQLCRUD.swift --- Sources/PerfectMySQL/MySQLCRUD.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) }