Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Sources/PerfectMySQL/MySQL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And param is ignored? Why removed my_bool? That's already fixed, it can be used without problems :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SkOODaT pls revert that change on this line

return mysql_options(mysqlPtr, exposedOptionToMySQLOption(option), &myB) == 0
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/PerfectMySQL/MySQLCRUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
10 changes: 7 additions & 3 deletions Sources/PerfectMySQL/MySQLStmt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<UInt8> = 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
}
Expand Down