mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-20 18:32:06 +00:00
implement -batch:
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@38714 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7a2a1c48a0
commit
f707d5bc9c
4 changed files with 36 additions and 14 deletions
|
@ -1,3 +1,10 @@
|
|||
2015-06-27 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* SQLClient.h:
|
||||
* SQLClient.m:
|
||||
* SQLClientPool.m:
|
||||
Implement -batch: method for client pools.
|
||||
|
||||
2015-06-26 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* SQLClient.h:
|
||||
|
|
|
@ -1577,6 +1577,11 @@ SQLCLIENT_PRIVATE
|
|||
*/
|
||||
- (int) availableConnections;
|
||||
|
||||
/** Creates and returns an autoreleased SQLTransaction instance which will
|
||||
* use the receiver as the database connection to perform transactions.
|
||||
*/
|
||||
- (SQLTransaction*) batch: (BOOL)stopOnFailure;
|
||||
|
||||
/**
|
||||
* Returns the cache used by clients in the pool for storing the results of
|
||||
* requests made through them. Creates a new cache if necessary.
|
||||
|
|
23
SQLClient.m
23
SQLClient.m
|
@ -89,7 +89,9 @@ static Class SQLClientClass = Nil;
|
|||
- (BOOL) _swallowClient: (SQLClient*)client withRetain: (BOOL)shouldRetain;
|
||||
@end
|
||||
@interface SQLTransaction (Creation)
|
||||
+ (SQLTransaction*) _transactionUsing: (id)clientOrPool;
|
||||
+ (SQLTransaction*) _transactionUsing: (id)clientOrPool
|
||||
batch: (BOOL)isBatched
|
||||
stop: (BOOL)stopOnFailure;
|
||||
@end
|
||||
|
||||
@implementation SQLRecordKeys
|
||||
|
@ -2783,16 +2785,9 @@ static int poolConnections = 0;
|
|||
|
||||
- (SQLTransaction*) batch: (BOOL)stopOnFailure
|
||||
{
|
||||
SQLTransaction *transaction;
|
||||
|
||||
transaction = (SQLTransaction*)NSAllocateObject([SQLTransaction class], 0,
|
||||
NSDefaultMallocZone());
|
||||
|
||||
transaction->_db = [self retain];
|
||||
transaction->_info = [NSMutableArray new];
|
||||
transaction->_batch = YES;
|
||||
transaction->_stop = stopOnFailure;
|
||||
return [(SQLTransaction*)transaction autorelease];
|
||||
return [SQLTransaction _transactionUsing: self
|
||||
batch: YES
|
||||
stop: stopOnFailure];
|
||||
}
|
||||
|
||||
- (NSMutableArray*) columns: (NSMutableArray*)records
|
||||
|
@ -2864,7 +2859,7 @@ static int poolConnections = 0;
|
|||
|
||||
- (SQLTransaction*) transaction
|
||||
{
|
||||
return [SQLTransaction _transactionUsing: self];
|
||||
return [SQLTransaction _transactionUsing: self batch: NO stop: NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -3125,6 +3120,8 @@ static int poolConnections = 0;
|
|||
@implementation SQLTransaction
|
||||
|
||||
+ (SQLTransaction*) _transactionUsing: (id)clientOrPool
|
||||
batch: (BOOL)isBatched
|
||||
stop: (BOOL)stopOnFailure
|
||||
{
|
||||
SQLTransaction *transaction;
|
||||
|
||||
|
@ -3133,6 +3130,8 @@ static int poolConnections = 0;
|
|||
|
||||
transaction->_db = [clientOrPool retain];
|
||||
transaction->_info = [NSMutableArray new];
|
||||
transaction->_batch = isBatched;
|
||||
transaction->_stop = stopOnFailure;
|
||||
return [transaction autorelease];
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,9 @@
|
|||
@end
|
||||
|
||||
@interface SQLTransaction (Creation)
|
||||
+ (SQLTransaction*) _transactionUsing: (id)clientOrPool;
|
||||
+ (SQLTransaction*) _transactionUsing: (id)clientOrPool
|
||||
batch: (BOOL)isBatched
|
||||
stop: (BOOL)stopOnFailure;
|
||||
@end
|
||||
|
||||
@implementation SQLClientPool
|
||||
|
@ -85,6 +87,13 @@
|
|||
return available;
|
||||
}
|
||||
|
||||
- (SQLTransaction*) batch: (BOOL)stopOnFailure
|
||||
{
|
||||
return [SQLTransaction _transactionUsing: self
|
||||
batch: YES
|
||||
stop: stopOnFailure];
|
||||
}
|
||||
|
||||
- (GSCache*) cache
|
||||
{
|
||||
return [c[0] cache];
|
||||
|
@ -755,7 +764,9 @@
|
|||
|
||||
- (SQLTransaction*) transaction
|
||||
{
|
||||
return [SQLTransaction _transactionUsing: self];
|
||||
return [SQLTransaction _transactionUsing: self
|
||||
batch: NO
|
||||
stop: NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue