 	private var db: OpaquePointer? = nil
 	private let mutex = Mutex()
 	private var counter = 0
+	private var hypotheticalCounter = 0
 	let dialect: SQLDialect = SQLStandardDialect()
 
 	enum DatabaseError: LocalizedError {

		return String(cString: sqlite3_errmsg(self.db))
	}

	func snapshot() -> Snapshot? {
		return self.mutex.locked {
			var sn: UnsafeMutablePointer<sqlite3_snapshot>? = nil
			return withUnsafeMutablePointer(to: &sn) { ptr in
				if sqlite3_snapshot_get(self.db, self.schema, ptr) != SQLITE_OK {
					return nil
				}
				return Snapshot(snapshot: sn!)
			}
		}
	}

	func transaction<T>(name: String? = nil, alwaysRollback: Bool, callback: (() throws -> (T))) throws -> T {
		let savepointName = self.dialect.literalString(name ?? "tx-\(self.counter)")

		try _ = self.perform("SAVEPOINT \(savepointName)")

		do {
			let t = try callback()

			if alwaysRollback {
				try _ = self.perform("ROLLBACK TO SAVEPOINT \(savepointName)")
			}
			else {
				try _ = self.perform("RELEASE SAVEPOINT \(savepointName)")
			}

			return t
		}
		catch {
			try! _ = self.perform("ROLLBACK TO SAVEPOINT \(savepointName)")
			throw error
		}
	}


						return SQLiteResult(database: self, resultset: resultSet!, rows: true)

					default:
						Log.debug("[SQL] ERROR: \(self.lastError)")
						throw DatabaseError.error(self.lastError)
					}
				}
				else {
					Log.debug("[SQL] ERROR in prepare: \(self.lastError)")
					throw DatabaseError.error(self.lastError)
				}
			}
