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
07d47a1e
Commit
07d47a1e
authored
8 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Renamed SqliteConn:m_conn to SqliteConn::m_sqliteConn
parent
e12dbca6
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
rdbms/SqliteConn.cpp
+15
-15
15 additions, 15 deletions
rdbms/SqliteConn.cpp
rdbms/SqliteConn.hpp
+1
-1
1 addition, 1 deletion
rdbms/SqliteConn.hpp
rdbms/SqliteStmt.cpp
+4
-4
4 additions, 4 deletions
rdbms/SqliteStmt.cpp
with
20 additions
and
20 deletions
rdbms/SqliteConn.cpp
+
15
−
15
View file @
07d47a1e
...
...
@@ -33,22 +33,22 @@ namespace rdbms {
SqliteConn
::
SqliteConn
(
const
std
::
string
&
filename
)
:
m_transactionInProgress
(
false
)
{
try
{
m_
c
onn
=
nullptr
;
if
(
sqlite3_open_v2
(
filename
.
c_str
(),
&
m_
c
onn
,
SQLITE_OPEN_READWRITE
|
SQLITE_OPEN_CREATE
|
SQLITE_OPEN_URI
,
nullptr
))
{
std
::
string
msg
=
sqlite3_errmsg
(
m_
c
onn
);
sqlite3_close
(
m_
c
onn
);
m_
sqliteC
onn
=
nullptr
;
if
(
sqlite3_open_v2
(
filename
.
c_str
(),
&
m_
sqliteC
onn
,
SQLITE_OPEN_READWRITE
|
SQLITE_OPEN_CREATE
|
SQLITE_OPEN_URI
,
nullptr
))
{
std
::
string
msg
=
sqlite3_errmsg
(
m_
sqliteC
onn
);
sqlite3_close
(
m_
sqliteC
onn
);
throw
exception
::
Exception
(
msg
);
}
{
char
*
errMsg
=
nullptr
;
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_
c
onn
,
"PRAGMA foreign_keys = ON;"
,
nullptr
,
nullptr
,
&
errMsg
))
{
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_
sqliteC
onn
,
"PRAGMA foreign_keys = ON;"
,
nullptr
,
nullptr
,
&
errMsg
))
{
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"Failed to to set PRAGMA foreign_keys = ON"
;
if
(
nullptr
!=
errMsg
)
{
ex
.
getMessage
()
<<
": "
<<
errMsg
;
sqlite3_free
(
errMsg
);
}
sqlite3_close
(
m_
c
onn
);
sqlite3_close
(
m_
sqliteC
onn
);
throw
ex
;
}
}
...
...
@@ -70,9 +70,9 @@ SqliteConn::~SqliteConn() throw() {
void
SqliteConn
::
close
()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
!=
m_
c
onn
)
{
sqlite3_close
(
m_
c
onn
);
m_
c
onn
=
nullptr
;
if
(
nullptr
!=
m_
sqliteC
onn
)
{
sqlite3_close
(
m_
sqliteC
onn
);
m_
sqliteC
onn
=
nullptr
;
}
}
...
...
@@ -83,7 +83,7 @@ std::unique_ptr<Stmt> SqliteConn::createStmt(const std::string &sql, const Stmt:
try
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
==
m_
c
onn
)
{
if
(
nullptr
==
m_
sqliteC
onn
)
{
throw
exception
::
Exception
(
"Connection is closed"
);
}
...
...
@@ -101,13 +101,13 @@ void SqliteConn::commit() {
try
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
==
m_
c
onn
)
{
if
(
nullptr
==
m_
sqliteC
onn
)
{
throw
exception
::
Exception
(
"Connection is closed"
);
}
if
(
m_transactionInProgress
)
{
char
*
errMsg
=
nullptr
;
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_
c
onn
,
"COMMIT"
,
nullptr
,
nullptr
,
&
errMsg
))
{
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_
sqliteC
onn
,
"COMMIT"
,
nullptr
,
nullptr
,
&
errMsg
))
{
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"sqlite3_exec failed"
;
if
(
nullptr
!=
errMsg
)
{
...
...
@@ -130,13 +130,13 @@ void SqliteConn::rollback() {
try
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
m_mutex
);
if
(
nullptr
==
m_
c
onn
)
{
if
(
nullptr
==
m_
sqliteC
onn
)
{
throw
exception
::
Exception
(
"Connection is closed"
);
}
if
(
m_transactionInProgress
)
{
char
*
errMsg
=
nullptr
;
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_
c
onn
,
"ROLLBACK"
,
nullptr
,
nullptr
,
&
errMsg
))
{
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_
sqliteC
onn
,
"ROLLBACK"
,
nullptr
,
nullptr
,
&
errMsg
))
{
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"sqlite3_exec failed"
;
if
(
nullptr
!=
errMsg
)
{
...
...
@@ -210,7 +210,7 @@ std::list<std::string> SqliteConn::getTableNames() {
// isOpen
//------------------------------------------------------------------------------
bool
SqliteConn
::
isOpen
()
const
{
return
nullptr
!=
m_
c
onn
;
return
nullptr
!=
m_
sqliteC
onn
;
}
}
// namespace rdbms
...
...
This diff is collapsed.
Click to expand it.
rdbms/SqliteConn.hpp
+
1
−
1
View file @
07d47a1e
...
...
@@ -115,7 +115,7 @@ private:
/**
* The database connection.
*/
sqlite3
*
m_
c
onn
;
sqlite3
*
m_
sqliteC
onn
;
/**
* True of there is an on-going transaction.
...
...
This diff is collapsed.
Click to expand it.
rdbms/SqliteStmt.cpp
+
4
−
4
View file @
07d47a1e
...
...
@@ -49,7 +49,7 @@ SqliteStmt::SqliteStmt(
const
uint
maxPrepareRetries
=
20
;
// A worst case scenario of 2 seconds
for
(
unsigned
int
i
=
0
;
i
<=
maxPrepareRetries
;
i
++
)
{
const
int
prepareRc
=
sqlite3_prepare_v2
(
m_conn
.
m_
c
onn
,
sql
.
c_str
(),
nByte
,
&
m_stmt
,
nullptr
);
const
int
prepareRc
=
sqlite3_prepare_v2
(
m_conn
.
m_
sqliteC
onn
,
sql
.
c_str
(),
nByte
,
&
m_stmt
,
nullptr
);
if
(
SQLITE_OK
==
prepareRc
)
{
break
;
...
...
@@ -71,7 +71,7 @@ SqliteStmt::SqliteStmt(
}
}
const
std
::
string
msg
=
sqlite3_errmsg
(
m_conn
.
m_
c
onn
);
const
std
::
string
msg
=
sqlite3_errmsg
(
m_conn
.
m_
sqliteC
onn
);
sqlite3_finalize
(
m_stmt
);
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed: sqlite3_prepare_v2 failed: "
+
msg
);
}
...
...
@@ -232,7 +232,7 @@ void SqliteStmt::executeNonQuery() {
Sqlite
::
rcToStr
(
stepRc
));
}
m_nbAffectedRows
=
sqlite3_changes
(
m_conn
.
m_
c
onn
);
m_nbAffectedRows
=
sqlite3_changes
(
m_conn
.
m_
sqliteC
onn
);
// Throw an exception if the SQL statement returned a result set
if
(
SQLITE_ROW
==
stepRc
)
{
...
...
@@ -254,7 +254,7 @@ uint64_t SqliteStmt::getNbAffectedRows() const {
void
SqliteStmt
::
beginExclusiveTransaction
()
{
try
{
char
*
errMsg
=
nullptr
;
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_conn
.
m_
c
onn
,
"BEGIN EXCLUSIVE"
,
nullptr
,
nullptr
,
&
errMsg
))
{
if
(
SQLITE_OK
!=
sqlite3_exec
(
m_conn
.
m_
sqliteC
onn
,
"BEGIN EXCLUSIVE"
,
nullptr
,
nullptr
,
&
errMsg
))
{
exception
::
Exception
ex
;
ex
.
getMessage
()
<<
"sqlite3_exec failed"
;
if
(
nullptr
!=
errMsg
)
{
...
...
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