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
a3db51bf
Commit
a3db51bf
authored
Sep 28, 2010
by
Orlando Vazquez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't bother to create a memory pool if there are no results
parent
ac7dbadf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
statement.cc
src/statement.cc
+21
-20
No files found.
src/statement.cc
View file @
a3db51bf
...
@@ -785,11 +785,14 @@ int Statement::EIO_AfterFetchAll(eio_req *req) {
...
@@ -785,11 +785,14 @@ int Statement::EIO_AfterFetchAll(eio_req *req) {
// max_alloced_p,
// max_alloced_p,
// tot_alloced_p
// tot_alloced_p
// );
// );
int
ret
=
mpool_close
(
fetchall_req
->
pool
);
if
(
ret
!=
MPOOL_ERROR_NONE
)
{
if
(
fetchall_req
->
rows
)
{
req
->
result
=
-
1
;
int
ret
=
mpool_close
(
fetchall_req
->
pool
);
argv
[
0
]
=
Exception
::
Error
(
String
::
New
(
mpool_strerror
(
ret
)));
if
(
ret
!=
MPOOL_ERROR_NONE
)
{
argv
[
1
]
=
Local
<
Value
>::
New
(
Undefined
());
req
->
result
=
-
1
;
argv
[
0
]
=
Exception
::
Error
(
String
::
New
(
mpool_strerror
(
ret
)));
argv
[
1
]
=
Local
<
Value
>::
New
(
Undefined
());
}
}
}
TryCatch
try_catch
;
TryCatch
try_catch
;
...
@@ -834,25 +837,24 @@ int Statement::EIO_FetchAll(eio_req *req) {
...
@@ -834,25 +837,24 @@ int Statement::EIO_FetchAll(eio_req *req) {
,
*
prev
=
NULL
,
*
prev
=
NULL
,
*
head
=
NULL
;
,
*
head
=
NULL
;
while
(
1
)
{
for
(;;
rc
=
sqlite3_step
(
stmt
))
{
int
rc
=
sqlite3_step
(
stmt
);
if
(
rc
!=
SQLITE_ROW
)
break
;
// TODO: test for != SQLITE_ROW (errors)
if
(
rc
==
SQLITE_DONE
)
{
break
;
}
if
(
!
sto
->
column_names_
)
{
if
(
!
sto
->
column_names_
)
{
sto
->
InitializeColumns
();
sto
->
InitializeColumns
();
}
}
cur
=
(
struct
row_node
*
)
mpool_alloc
(
fetchall_req
->
pool
cur
=
(
struct
row_node
*
)
mpool_alloc
,
sizeof
(
struct
row_node
)
(
fetchall_req
->
pool
,
&
ret
);
,
sizeof
(
struct
row_node
)
,
&
ret
);
cur
->
next
=
NULL
;
cur
->
next
=
NULL
;
// If this is the first row,
set head to cur and hold it there since it
// If this is the first row,
assign `cur` to `head` and `hold` head there
//
was the first result. Otherwise set the `next` field on the `prev`
//
since it was the first result. Otherwise set the `next` field on
// pointer to attach the newly allocated element.
//
the`prev`
pointer to attach the newly allocated element.
(
!
head
?
head
:
prev
->
next
)
=
cur
;
(
!
head
?
head
:
prev
->
next
)
=
cur
;
struct
cell_node
*
cell_head
=
NULL
struct
cell_node
*
cell_head
=
NULL
...
@@ -863,14 +865,13 @@ int Statement::EIO_FetchAll(eio_req *req) {
...
@@ -863,14 +865,13 @@ int Statement::EIO_FetchAll(eio_req *req) {
cell
=
(
struct
cell_node
*
)
cell
=
(
struct
cell_node
*
)
mpool_alloc
(
fetchall_req
->
pool
,
sizeof
(
struct
cell_node
),
&
ret
);
mpool_alloc
(
fetchall_req
->
pool
,
sizeof
(
struct
cell_node
),
&
ret
);
// If this is the first cell, set cell_head to cell and hold it there
// Same as above with the row linked list.
// since it was the first result. Otherwise set the `next` field on the
// `prev` pointer to attach the newly allocated element.
(
!
cell_head
?
cell_head
:
cell_prev
->
next
)
=
cell
;
(
!
cell_head
?
cell_head
:
cell_prev
->
next
)
=
cell
;
cell
->
type
=
sqlite3_column_type
(
sto
->
stmt_
,
i
);
cell
->
type
=
sqlite3_column_type
(
sto
->
stmt_
,
i
);
cell
->
next
=
NULL
;
cell
->
next
=
NULL
;
// TODO: Cache column data in the fetchall req struct.
switch
(
cell
->
type
)
{
switch
(
cell
->
type
)
{
case
SQLITE_INTEGER
:
case
SQLITE_INTEGER
:
cell
->
value
=
(
int
*
)
cell
->
value
=
(
int
*
)
...
...
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