mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-14 15:40:59 +00:00
fix for #47178
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@39394 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dc0eb8406a
commit
1664989106
5 changed files with 1619 additions and 4021 deletions
|
@ -1,3 +1,10 @@
|
|||
2016-02-18 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* configure.ac: get host and cpu with more recent gnustep-make
|
||||
* configure: regenerate
|
||||
* JDBC.m: Update for connection pools (bug #47178)
|
||||
* testJDBC.m: get rid of compiler warnings
|
||||
|
||||
2015-07-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Postgres.m: disconnect on fatal error, so we don't keep trying to
|
||||
|
|
55
JDBC.m
55
JDBC.m
|
@ -1521,7 +1521,7 @@ static int JDBCVARCHAR = 0;
|
|||
transaction = (_JDBCTransaction*)NSAllocateObject([_JDBCTransaction class], 0,
|
||||
NSDefaultMallocZone());
|
||||
|
||||
transaction->_db = [self retain];
|
||||
transaction->_owner = [self retain];
|
||||
transaction->_info = [NSMutableArray new];
|
||||
transaction->_batch = YES;
|
||||
transaction->_stop = stopOnFailure;
|
||||
|
@ -1680,7 +1680,7 @@ static int JDBCVARCHAR = 0;
|
|||
transaction = (_JDBCTransaction*)NSAllocateObject([_JDBCTransaction class], 0,
|
||||
NSDefaultMallocZone());
|
||||
|
||||
transaction->_db = [self retain];
|
||||
transaction->_owner = [self retain];
|
||||
transaction->_info = [NSMutableArray new];
|
||||
return [(SQLTransaction*)transaction autorelease];
|
||||
}
|
||||
|
@ -1728,21 +1728,13 @@ static int JDBCVARCHAR = 0;
|
|||
if (_count > 0)
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
SQLClientPool *pool;
|
||||
SQLClient *db;
|
||||
BOOL wrapped = NO;
|
||||
BOOL batched = NO;
|
||||
JNIEnv *env;
|
||||
JInfo *ji;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([_db connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute transaction %@",
|
||||
[_db name], self];
|
||||
}
|
||||
|
||||
env = SQLClientJNIEnv();
|
||||
if ((*env)->PushLocalFrame (env, 32) < 0)
|
||||
{
|
||||
|
@ -1752,16 +1744,38 @@ static int JDBCVARCHAR = 0;
|
|||
format: @"No java memory for execute"];
|
||||
}
|
||||
|
||||
ji = [(SQLClientJDBC*)_db _backendExtra];
|
||||
if ([_owner isKindOfClass: [SQLClientPool class]])
|
||||
{
|
||||
pool = (SQLClientPool*)_owner;
|
||||
db = [pool provideClient];
|
||||
}
|
||||
else
|
||||
{
|
||||
pool = nil;
|
||||
db = _owner;
|
||||
}
|
||||
|
||||
ji = [(SQLClientJDBC*)db _backendExtra];
|
||||
|
||||
NS_DURING
|
||||
{
|
||||
NSMutableArray *statements;
|
||||
unsigned numberOfStatements;
|
||||
unsigned statement;
|
||||
NSTimeInterval _duration = [_db durationLogging];
|
||||
NSTimeInterval _duration;
|
||||
NSTimeInterval start = 0.0;
|
||||
|
||||
/*
|
||||
* Ensure we have a working connection.
|
||||
*/
|
||||
if ([db connect] == NO)
|
||||
{
|
||||
[NSException raise: SQLException
|
||||
format: @"Unable to connect to '%@' to execute transaction %@",
|
||||
[_owner name], self];
|
||||
}
|
||||
|
||||
_duration = [db durationLogging];
|
||||
statements = [NSMutableArray arrayWithCapacity: 100];
|
||||
[self _merge: statements];
|
||||
numberOfStatements = [statements count];
|
||||
|
@ -1771,7 +1785,7 @@ static int JDBCVARCHAR = 0;
|
|||
start = GSTickerTimeNow();
|
||||
}
|
||||
|
||||
if ([_db isInTransaction] == NO)
|
||||
if ([db isInTransaction] == NO)
|
||||
{
|
||||
wrapped = YES;
|
||||
}
|
||||
|
@ -1883,15 +1897,15 @@ static int JDBCVARCHAR = 0;
|
|||
|
||||
(*env)->PopLocalFrame (env, NULL);
|
||||
|
||||
_db->_lastOperation = GSTickerTimeNow();
|
||||
db->_lastOperation = GSTickerTimeNow();
|
||||
if (_duration >= 0)
|
||||
{
|
||||
NSTimeInterval d;
|
||||
|
||||
d = _db->_lastOperation - start;
|
||||
d = db->_lastOperation - start;
|
||||
if (d >= _duration)
|
||||
{
|
||||
[_db debug: @"Duration %g for transaction %@",
|
||||
[db debug: @"Duration %g for transaction %@",
|
||||
d, statements];
|
||||
}
|
||||
}
|
||||
|
@ -1913,6 +1927,11 @@ static int JDBCVARCHAR = 0;
|
|||
}
|
||||
NS_ENDHANDLER
|
||||
|
||||
if (nil != pool)
|
||||
{
|
||||
[pool swallowClient: db];
|
||||
}
|
||||
|
||||
[arp release];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ else
|
|||
. $GNUSTEP_MAKEFILES/GNUstep.sh
|
||||
fi
|
||||
|
||||
if test "x$GNUSTEP_HOST_OS" = "x"; then
|
||||
GNUSTEP_HOST_OS=`gnustep-config --variable=GNUSTEP_HOST_OS`
|
||||
GNUSTEP_HOST_CPU=`gnustep-config --variable=GNUSTEP_HOST_CPU`
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
AC_ARG_WITH(additional-include, [
|
||||
--with-additional-include=flags
|
||||
|
|
|
@ -125,7 +125,7 @@ main()
|
|||
if (count == 0)
|
||||
{
|
||||
[db commit];
|
||||
sleep(1);
|
||||
[NSThread sleepForTimeInterval: 1.0];
|
||||
[db begin];
|
||||
records = [db query: @"SELECT * FROM Queue WHERE Consumer = ",
|
||||
[db quote: name],
|
||||
|
@ -242,7 +242,7 @@ main()
|
|||
r0 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
r1 = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] == [r1 lastObject], @"Cache failed");
|
||||
sleep(2);
|
||||
[NSThread sleepForTimeInterval: 2.0];
|
||||
records = [db cache: 1 query: @"select * from xxx", nil];
|
||||
NSCAssert([r0 lastObject] != [records lastObject], @"Lifetime failed");
|
||||
|
||||
|
@ -250,7 +250,7 @@ main()
|
|||
|
||||
if ([records count] != 3)
|
||||
{
|
||||
NSLog(@"Expected 3 records but got %u", [records count]);
|
||||
NSLog(@"Expected 3 records but got %"PRIuPTR, [records count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue