Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
51647a15
Commit
51647a15
authored
5 years ago
by
Michael Davis
Browse files
Options
Downloads
Patches
Plain Diff
[migration] Moves OracleDbConn.hpp into migration/gRPC
parent
c15ab344
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
upgrade_db/OracleDbConn.hpp
+0
-90
0 additions, 90 deletions
upgrade_db/OracleDbConn.hpp
upgrade_db/UpgradeDB.cpp
+1
-1
1 addition, 1 deletion
upgrade_db/UpgradeDB.cpp
with
1 addition
and
91 deletions
upgrade_db/OracleDbConn.hpp
deleted
100644 → 0
+
0
−
90
View file @
c15ab344
/*!
* @project The CERN Tape Archive (CTA)
* @brief Access Oracle DB for migration operations
* @copyright Copyright 2019 CERN
* @license This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
<common/make_unique.hpp>
#include
<rdbms/Login.hpp>
#include
<rdbms/ConnPool.hpp>
namespace
cta
{
namespace
migration
{
/*!
* Manage a single database query over a single database connection
*/
class
OracleDbConn
{
public:
OracleDbConn
()
:
m_queryIsEmpty
(
true
)
{}
void
connect
(
const
std
::
string
&
dbconn
=
""
,
unsigned
int
max_num_conns
=
1
)
{
// Initialise the connection pool
if
(
!
dbconn
.
empty
())
{
m_connPool
.
reset
(
new
rdbms
::
ConnPool
(
rdbms
::
Login
::
parseString
(
dbconn
),
max_num_conns
));
}
// Initialise this connection
m_conn
=
m_connPool
->
getConn
();
}
void
execute
(
const
std
::
string
&
sqlString
)
{
auto
sql
=
m_conn
.
createStmt
(
sqlString
);
sql
.
executeNonQuery
();
}
void
query
(
const
std
::
string
&
sqlString
)
{
auto
sql
=
m_conn
.
createStmt
(
sqlString
);
m_rSet
=
cta
::
make_unique
<
rdbms
::
Rset
>
(
sql
.
executeQuery
());
m_queryIsEmpty
=
!
m_rSet
->
next
();
}
void
reset
()
{
m_rSet
.
reset
();
m_queryIsEmpty
=
true
;
}
bool
nextRow
()
{
if
(
m_rSet
->
next
())
return
true
;
reset
();
return
false
;
}
std
::
string
getResultColumnString
(
const
std
::
string
&
col
)
const
{
return
m_rSet
->
columnString
(
col
);
}
uint64_t
getResultColumnUint64
(
const
std
::
string
&
col
)
const
{
return
m_rSet
->
columnUint64
(
col
);
}
std
::
string
getResultColumnBlob
(
const
std
::
string
&
col
)
const
{
return
m_rSet
->
columnBlob
(
col
);
}
bool
isQueryEmpty
()
const
{
return
m_queryIsEmpty
;
}
private
:
static
std
::
unique_ptr
<
rdbms
::
ConnPool
>
m_connPool
;
//!< The pool of connections to the database
rdbms
::
Conn
m_conn
;
//!< The connection we are using
std
::
unique_ptr
<
rdbms
::
Rset
>
m_rSet
;
//!< Result set for the last query executed
bool
m_queryIsEmpty
;
//!< Track whether the last query had an empty result set
};
}}
// namespace cta::migration
This diff is collapsed.
Click to expand it.
upgrade_db/UpgradeDB.cpp
+
1
−
1
View file @
51647a15
...
...
@@ -23,7 +23,7 @@
#include
<XrdSsiPbConfig.hpp>
#include
<common/exception/Exception.hpp>
#include
<common/checksum/ChecksumBlob.hpp>
#include
"
OracleDbConn.hpp
"
#include
<migration/gRPC/
OracleDbConn.hpp
>
namespace
cta
{
namespace
migration
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment