Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
0db8772b
Commit
0db8772b
authored
Dec 18, 2019
by
Pavel Vainerman
Committed by
Pavel Vainerman
Dec 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DBServer_PostgresSQL: fixed "ping" and "is_open" processing
parent
e77967fc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
3 deletions
+33
-3
DBServer_PostgreSQL.cc
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
+1
-1
PostgreSQLInterface.cc
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
+28
-2
PostgreSQLInterface.h
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
+4
-0
No files found.
extensions/DBServer-PostgreSQL/DBServer_PostgreSQL.cc
View file @
0db8772b
...
@@ -383,7 +383,7 @@ void DBServer_PostgreSQL::initDBServer()
...
@@ -383,7 +383,7 @@ void DBServer_PostgreSQL::initDBServer()
<<
" pingTime="
<<
PingTime
<<
" pingTime="
<<
PingTime
<<
" ReconnectTime="
<<
ReconnectTime
<<
endl
;
<<
" ReconnectTime="
<<
ReconnectTime
<<
endl
;
if
(
!
db
->
n
connect
(
dbnode
,
dbuser
,
dbpass
,
dbname
,
dbport
)
)
if
(
!
db
->
re
connect
(
dbnode
,
dbuser
,
dbpass
,
dbname
,
dbport
)
)
{
{
dbwarn
<<
myname
<<
"(init): DB connection error: "
<<
db
->
error
()
<<
endl
;
dbwarn
<<
myname
<<
"(init): DB connection error: "
<<
db
->
error
()
<<
endl
;
askTimer
(
DBServer_PostgreSQL
::
ReconnectTimer
,
ReconnectTime
);
askTimer
(
DBServer_PostgreSQL
::
ReconnectTimer
,
ReconnectTime
);
...
...
extensions/DBServer-PostgreSQL/PostgreSQLInterface.cc
View file @
0db8772b
...
@@ -47,7 +47,32 @@ PostgreSQLInterface::~PostgreSQLInterface()
...
@@ -47,7 +47,32 @@ PostgreSQLInterface::~PostgreSQLInterface()
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
ping
()
const
bool
PostgreSQLInterface
::
ping
()
const
{
{
return
db
&&
db
->
is_open
();
if
(
!
db
)
return
false
;
try
{
nontransaction
n
(
*
(
db
.
get
()));
n
.
exec
(
"select version();"
);
return
true
;
}
catch
(
const
std
::
exception
&
e
)
{
// lastE = string(e.what());
}
return
false
;
// return db && db->is_open();
}
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
reconnect
(
const
string
&
host
,
const
string
&
user
,
const
string
&
pswd
,
const
string
&
dbname
,
unsigned
int
port
)
{
if
(
db
)
close
();
return
nconnect
(
host
,
user
,
pswd
,
dbname
,
port
);
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
nconnect
(
const
string
&
host
,
const
string
&
user
,
const
string
&
pswd
,
const
string
&
dbname
,
unsigned
int
port
)
bool
PostgreSQLInterface
::
nconnect
(
const
string
&
host
,
const
string
&
user
,
const
string
&
pswd
,
const
string
&
dbname
,
unsigned
int
port
)
...
@@ -224,7 +249,8 @@ void PostgreSQLInterface::save_inserted_id( const pqxx::result& res )
...
@@ -224,7 +249,8 @@ void PostgreSQLInterface::save_inserted_id( const pqxx::result& res )
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
bool
PostgreSQLInterface
::
isConnection
()
const
bool
PostgreSQLInterface
::
isConnection
()
const
{
{
return
(
db
&&
db
->
is_open
());
return
db
&&
ping
();
// return (db && db->is_open())
}
}
// -----------------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------------
DBResult
PostgreSQLInterface
::
makeResult
(
const
pqxx
::
result
&
res
)
DBResult
PostgreSQLInterface
::
makeResult
(
const
pqxx
::
result
&
res
)
...
...
extensions/DBServer-PostgreSQL/PostgreSQLInterface.h
View file @
0db8772b
...
@@ -61,6 +61,10 @@ namespace uniset
...
@@ -61,6 +61,10 @@ namespace uniset
virtual
const
std
::
string
error
()
override
;
virtual
const
std
::
string
error
()
override
;
bool
reconnect
(
const
std
::
string
&
host
,
const
std
::
string
&
user
,
const
std
::
string
&
pswd
,
const
std
::
string
&
dbname
,
unsigned
int
port
=
5432
);
protected
:
protected
:
private
:
private
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment