Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
937902dc
Commit
937902dc
authored
Jan 29, 2011
by
Steven Ashley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added error handling to Statement::FetchAll.
parent
409251a0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
4 deletions
+20
-4
statement.cc
src/statement.cc
+20
-4
No files found.
src/statement.cc
View file @
937902dc
...
...
@@ -708,7 +708,7 @@ int Statement::EIO_AfterFetchAll(eio_req *req) {
Local
<
Value
>
argv
[
2
];
if
(
req
->
result
)
{
if
(
fetchall_req
->
error
!=
NULL
)
{
argv
[
0
]
=
Exception
::
Error
(
String
::
New
(
fetchall_req
->
error
));
argv
[
1
]
=
Local
<
Value
>::
New
(
Undefined
());
}
...
...
@@ -787,7 +787,7 @@ int Statement::EIO_AfterFetchAll(eio_req *req) {
// tot_alloced_p
// );
if
(
fetchall_req
->
rows
)
{
if
(
fetchall_req
->
pool
)
{
int
ret
=
mpool_close
(
fetchall_req
->
pool
);
if
(
ret
!=
MPOOL_ERROR_NONE
)
{
req
->
result
=
-
1
;
...
...
@@ -824,7 +824,7 @@ int Statement::EIO_FetchAll(eio_req *req) {
int
rc
=
sqlite3_step
(
stmt
);
if
(
rc
==
SQLITE_ROW
)
{
if
(
rc
!=
SQLITE_DONE
)
{
/* open the pool */
fetchall_req
->
pool
=
mpool_open
(
MPOOL_FLAG_USE_MAP_ANON
,
0
...
...
@@ -850,7 +850,6 @@ int Statement::EIO_FetchAll(eio_req *req) {
for
(;;
rc
=
sqlite3_step
(
stmt
))
{
if
(
rc
!=
SQLITE_ROW
)
break
;
// TODO: test for != SQLITE_ROW (errors)
if
(
!
sto
->
column_names_
)
{
sto
->
InitializeColumns
();
...
...
@@ -929,6 +928,23 @@ int Statement::EIO_FetchAll(eio_req *req) {
prev
=
cur
;
}
// Test for errors
if
(
rc
!=
SQLITE_DONE
)
{
const
char
*
error
=
sqlite3_errmsg
(
sqlite3_db_handle
(
sto
->
stmt_
));
if
(
error
==
NULL
)
{
error
=
"Unknown Error"
;
}
size_t
errorSize
=
sizeof
(
char
)
*
(
strlen
(
error
)
+
1
);
fetchall_req
->
error
=
(
char
*
)
mpool_alloc
(
fetchall_req
->
pool
,
errorSize
,
&
ret
);
if
(
fetchall_req
->
error
!=
NULL
)
{
memcpy
(
fetchall_req
->
error
,
error
,
errorSize
);
}
else
{
fetchall_req
->
error
=
(
char
*
)
mpool_strerror
(
ret
);
}
req
->
result
=
-
1
;
return
0
;
}
req
->
result
=
0
;
fetchall_req
->
rows
=
head
;
...
...
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