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
376b80cf
Commit
376b80cf
authored
8 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
SQL statements in exceptions clipped to 80 chars
parent
1d2ad909
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
rdbms/OcciStmt.cpp
+20
-14
20 additions, 14 deletions
rdbms/OcciStmt.cpp
rdbms/SqliteStmt.cpp
+14
-13
14 additions, 13 deletions
rdbms/SqliteStmt.cpp
rdbms/Stmt.hpp
+5
-0
5 additions, 0 deletions
rdbms/Stmt.hpp
with
39 additions
and
27 deletions
rdbms/OcciStmt.cpp
+
20
−
14
View file @
376b80cf
...
...
@@ -59,11 +59,12 @@ OcciStmt::OcciStmt(
}
}
catch
(
exception
::
Exception
&
ex
)
{
close
();
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
+
": "
+
ex
.
getMessage
().
str
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
.
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
getMessage
().
str
());
}
catch
(
std
::
exception
&
se
)
{
close
();
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
+
": "
+
se
.
what
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
.
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
se
.
what
());
}
}
...
...
@@ -90,10 +91,11 @@ void OcciStmt::close() {
m_stmt
=
nullptr
;
}
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
ex
.
getMessage
().
str
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
getMessage
().
str
());
}
catch
(
std
::
exception
&
se
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
se
.
what
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
se
.
what
());
}
}
...
...
@@ -128,10 +130,11 @@ void OcciStmt::bindOptionalUint64(const std::string ¶mName, const optional<u
m_stmt
->
setNull
(
paramIdx
,
oracle
::
occi
::
OCCINUMBER
);
}
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
ex
.
getMessage
().
str
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
getMessage
().
str
());
}
catch
(
std
::
exception
&
se
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
se
.
what
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
se
.
what
());
}
}
...
...
@@ -163,10 +166,11 @@ void OcciStmt::bindOptionalString(const std::string ¶mName, const optional<s
m_stmt
->
setNull
(
paramIdx
,
oracle
::
occi
::
OCCISTRING
);
}
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
ex
.
getMessage
().
str
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
getMessage
().
str
());
}
catch
(
std
::
exception
&
se
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
se
.
what
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
se
.
what
());
}
}
...
...
@@ -191,7 +195,8 @@ std::unique_ptr<Rset> OcciStmt::executeQuery() {
}
catch
(...)
{
}
}
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
ex
.
what
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
what
());
}
}
...
...
@@ -216,7 +221,8 @@ void OcciStmt::executeNonQuery() {
}
catch
(...)
{
}
}
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
ex
.
what
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
what
());
}
}
...
...
This diff is collapsed.
Click to expand it.
rdbms/SqliteStmt.cpp
+
14
−
13
View file @
376b80cf
...
...
@@ -94,11 +94,12 @@ SqliteStmt::SqliteStmt(
}
}
catch
(
exception
::
Exception
&
ex
)
{
close
();
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
+
": "
+
ex
.
getMessage
().
str
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
.
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
getMessage
().
str
());
}
catch
(
std
::
exception
&
se
)
{
close
();
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
+
": "
+
se
.
what
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
sql
.
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
se
.
what
());
}
}
...
...
@@ -130,8 +131,8 @@ void SqliteStmt::close() {
//------------------------------------------------------------------------------
sqlite3_stmt
*
SqliteStmt
::
get
()
const
{
if
(
nullptr
==
m_stmt
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": nullptr pointer"
);
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": nullptr pointer"
);
}
return
m_stmt
;
}
...
...
@@ -170,8 +171,8 @@ void SqliteStmt::bindOptionalUint64(const std::string ¶mName, const optional
throw
exception
::
Exception
(
"sqlite3_bind_int64() failed"
);
}
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
ex
.
getMessage
().
str
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
getMessage
().
str
());
}
}
...
...
@@ -206,8 +207,8 @@ void SqliteStmt::bindOptionalString(const std::string ¶mName, const optional
throw
exception
::
Exception
(
"sqlite3_bind_text() failed"
);
}
}
catch
(
exception
::
Exception
&
ex
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
ex
.
getMessage
().
str
());
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
ex
.
getMessage
().
str
());
}
}
...
...
@@ -228,16 +229,16 @@ void SqliteStmt::executeNonQuery() {
// Throw an exception if the call to sqlite3_step() failed
if
(
SQLITE_DONE
!=
stepRc
&&
SQLITE_ROW
!=
stepRc
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": "
+
Sqlite
::
rcToStr
(
stepRc
));
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": "
+
Sqlite
::
rcToStr
(
stepRc
));
}
m_nbAffectedRows
=
sqlite3_changes
(
m_conn
.
m_sqliteConn
);
// Throw an exception if the SQL statement returned a result set
if
(
SQLITE_ROW
==
stepRc
)
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
()
+
": The SQL statment returned a result set"
);
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" failed for SQL statement "
+
getSql
().
substr
(
0
,
c_maxSqlLenInExceptions
)
+
": The SQL statment returned a result set"
);
}
}
...
...
This diff is collapsed.
Click to expand it.
rdbms/Stmt.hpp
+
5
−
0
View file @
376b80cf
...
...
@@ -177,6 +177,11 @@ protected:
*/
AutocommitMode
m_autoCommitMode
;
/**
* The maximum length an SQL statement can have in exception error message.
*/
const
uint32_t
c_maxSqlLenInExceptions
=
80
;
};
// class Stmt
}
// namespace rdbms
...
...
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