From 79eff5bf42154da8d7730e0e0159160f68ec4e16 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 14 Mar 2012 01:16:18 +0000 Subject: =?UTF-8?q?Final=20feature=20work=20on=20the=20SPMySQL=20branch=20?= =?UTF-8?q?before=20merging:=20=20-=20Add=20a=20ping=20keepalive=20managin?= =?UTF-8?q?g=20object=20to=20prevent=20retain=20cycles=20from=20the=20NSTi?= =?UTF-8?q?mer=20=20-=20Add=20-[SPMySQLConnection=20copy]=20support=20=20-?= =?UTF-8?q?=20Refactor=20Hans-J=C3=B6rg=20Bibiko's=20database=20structure?= =?UTF-8?q?=20retrieval,=20moving=20it=20out=20of=20the=20MySQL=20framewor?= =?UTF-8?q?k=20and=20building=20it=20around=20a=20copy=20of=20the=20connec?= =?UTF-8?q?tion.=20=20This=20reduces=20the=20amount=20of=20connections-ove?= =?UTF-8?q?r-time=20used=20by=20Sequel=20Pro=20to=20two=20constant=20conne?= =?UTF-8?q?ctions=20(addressing=20Issue=20#1097)=20and=20improves=20robust?= =?UTF-8?q?ness.=20=20-=20Use=20the=20database=20structure=20retrieval=20c?= =?UTF-8?q?onnection=20for=20faster=20query=20cancellation=20without=20an?= =?UTF-8?q?=20extra=20connection=20required,=20if=20possible?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Source/SPMySQLConnection Categories/Copying.m | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m (limited to 'Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m') diff --git a/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m new file mode 100644 index 00000000..c2df2a4b --- /dev/null +++ b/Frameworks/SPMySQLFramework/Source/SPMySQLConnection Categories/Copying.m @@ -0,0 +1,71 @@ +// +// $Id$ +// +// Copying.m +// SPMySQLFramework +// +// Created by Rowan Beentje (rowan.beent.je) on March 8, 2012 +// Copyright (c) 2012 Rowan Beentje. All rights reserved. +// +// Permission is hereby granted, free of charge, to any person +// obtaining a copy of this software and associated documentation +// files (the "Software"), to deal in the Software without +// restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +// OTHER DEALINGS IN THE SOFTWARE. +// +// More info at + +#import "Copying.h" + +@implementation SPMySQLConnection (Copying) + +/** + * Provide a copy of the SPMySQLConnection instance. + * The copy should inherit the full setup, but will not inherit + * the connection state - it will not be connected, and any connection + * details such as the selected database/encoding will not be inherited. + * Note that any proxy will not be referenced in the new connection, and + * should also be set if desired. + */ +- (id)copyWithZone:(NSZone *)zone +{ + SPMySQLConnection *copy = [[[self class] allocWithZone:zone] init]; + + // Synthesized details + [copy setDelegate:delegate]; + [copy setHost:host]; + [copy setUsername:username]; + [copy setPassword:password]; + [copy setPort:port]; + [copy setUseSocket:useSocket]; + [copy setSocketPath:socketPath]; + [copy setUseSSL:useSSL]; + [copy setSslKeyFilePath:sslKeyFilePath]; + [copy setSslCertificatePath:sslCertificatePath]; + [copy setSslCACertificatePath:sslCACertificatePath]; + [copy setTimeout:timeout]; + [copy setUseKeepAlive:useKeepAlive]; + [copy setRetryQueriesOnConnectionFailure:retryQueriesOnConnectionFailure]; + [copy setDelegateQueryLogging:delegateQueryLogging]; + + // Active connection state details, like selected database and encoding, are *not* copied. + + return copy; +} + +@end -- cgit v1.2.3