mirror of
https://github.com/gnustep/libs-sqlclient.git
synced 2025-02-21 02:41:07 +00:00
Improve handling of server failure
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/sqlclient/trunk@38974 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
dc97e17119
commit
8016da7fad
2 changed files with 36 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2015-07-22 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Postgres.m: disconnect on fatal error, so we don't keep trying to
|
||||||
|
re-use the same connection when there's a problem with the server.
|
||||||
|
|
||||||
2015-07-23 Wolfgang Lux <wolfgang.lux@gmail.com>
|
2015-07-23 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
* SQLClient.m (initialize): Restore initialization of NSDateClass
|
* SQLClient.m (initialize): Restore initialization of NSDateClass
|
||||||
|
|
35
Postgres.m
35
Postgres.m
|
@ -430,18 +430,36 @@ connectQuote(NSString *str)
|
||||||
p = PQparameterStatus(connection, "standard_conforming_strings");
|
p = PQparameterStatus(connection, "standard_conforming_strings");
|
||||||
if (p != 0)
|
if (p != 0)
|
||||||
{
|
{
|
||||||
|
PGresult *result;
|
||||||
|
|
||||||
/* If the escape_string_warning setting is on,
|
/* If the escape_string_warning setting is on,
|
||||||
* the server will warn about backslashes even
|
* the server will warn about backslashes even
|
||||||
* in properly quoted strings, so turn it off.
|
* in properly quoted strings, so turn it off.
|
||||||
*/
|
*/
|
||||||
if (strcmp(p, "on") == 0)
|
if (strcmp(p, "on") == 0)
|
||||||
{
|
{
|
||||||
[self execute: @"SET escape_string_warning=off", nil];
|
result = PQexec(connection,
|
||||||
|
"SET escape_string_warning=off");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self execute: @"SET standard_conforming_strings=on;"
|
result = PQexec(connection,
|
||||||
@"SET escape_string_warning=off", nil];
|
"SET standard_conforming_strings=on;"
|
||||||
|
"SET escape_string_warning=off");
|
||||||
|
}
|
||||||
|
if (0 == result
|
||||||
|
|| PQresultStatus(result) != PGRES_COMMAND_OK)
|
||||||
|
{
|
||||||
|
[self debug: @"Error setting string handling"
|
||||||
|
@" with '%@' (%@) - %s",
|
||||||
|
[self name], m, PQerrorMessage(connection)];
|
||||||
|
if (result != 0)
|
||||||
|
{
|
||||||
|
PQclear(result);
|
||||||
|
}
|
||||||
|
PQfinish(connection);
|
||||||
|
connection = 0;
|
||||||
|
connected = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -454,7 +472,14 @@ connectQuote(NSString *str)
|
||||||
|
|
||||||
if ([self debugging] > 0)
|
if ([self debugging] > 0)
|
||||||
{
|
{
|
||||||
[self debug: @"Connected to '%@'", [self name]];
|
if (YES == connected)
|
||||||
|
{
|
||||||
|
[self debug: @"Connected to '%@'", [self name]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self debug: @"Disconnected '%@'", [self name]];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -634,6 +659,7 @@ connectQuote(NSString *str)
|
||||||
{
|
{
|
||||||
str = [NSString stringWithCString: cstr];
|
str = [NSString stringWithCString: cstr];
|
||||||
}
|
}
|
||||||
|
[self backendDisconnect];
|
||||||
[NSException raise: SQLException format: @"Error executing %@: %@",
|
[NSException raise: SQLException format: @"Error executing %@: %@",
|
||||||
stmt, str];
|
stmt, str];
|
||||||
}
|
}
|
||||||
|
@ -989,6 +1015,7 @@ static inline unsigned int trim(char *str, unsigned len)
|
||||||
{
|
{
|
||||||
str = [NSString stringWithCString: cstr];
|
str = [NSString stringWithCString: cstr];
|
||||||
}
|
}
|
||||||
|
[self backendDisconnect];
|
||||||
[NSException raise: SQLException format: @"Error executing %@: %@",
|
[NSException raise: SQLException format: @"Error executing %@: %@",
|
||||||
stmt, str];
|
stmt, str];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue