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
aefb3cc4
Commit
aefb3cc4
authored
Sep 09, 2010
by
Orlando Vazquez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a linked list for `statement.step`
parent
d8e7c186
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
143 deletions
+102
-143
statement.cc
src/statement.cc
+75
-111
statement.h
src/statement.h
+22
-27
speedtest.js
tests/old/speedtest.js
+1
-1
test-statement-step.js
tests/test-statement-step.js
+4
-4
No files found.
src/statement.cc
View file @
aefb3cc4
This diff is collapsed.
Click to expand it.
src/statement.h
View file @
aefb3cc4
...
...
@@ -30,6 +30,24 @@ extern "C" {
using
namespace
v8
;
using
namespace
node
;
struct
cell_node
{
void
*
value
;
int
type
;
struct
cell_node
*
next
;
};
struct
row_node
{
struct
cell_node
*
cells
;
struct
row_node
*
next
;
};
// represent strings with this struct
struct
string_t
{
size_t
bytes
;
char
data
[];
};
class
Statement
:
public
EventEmitter
{
public
:
...
...
@@ -43,16 +61,12 @@ class Statement : public EventEmitter {
Statement
(
sqlite3_stmt
*
stmt
,
int
first_rc
=
-
1
,
int
mode
=
0
)
:
EventEmitter
(),
first_rc_
(
first_rc
),
mode_
(
mode
),
stmt_
(
stmt
)
{
column_count_
=
-
1
;
column_types_
=
NULL
;
column_names_
=
NULL
;
column_data_
=
NULL
;
}
~
Statement
()
{
if
(
stmt_
)
sqlite3_finalize
(
stmt_
);
if
(
column_types_
)
free
(
column_types_
);
if
(
column_names_
)
free
(
column_names_
);
if
(
column_data_
)
FreeColumnData
();
if
(
column_names_
)
FreeColumnData
();
}
static
Handle
<
Value
>
Bind
(
const
Arguments
&
args
);
...
...
@@ -87,14 +101,15 @@ class Statement : public EventEmitter {
private
:
int
column_count_
;
int
*
column_types_
;
char
**
column_names_
;
void
**
column_data_
;
bool
error_
;
int
first_rc_
;
int
mode_
;
sqlite3_stmt
*
stmt_
;
// for statment.step
cell_node
*
cells
;
};
// indicates the key type (integer index or name string)
...
...
@@ -128,20 +143,6 @@ struct bind_pair {
size_t
value_size
;
};
// Results will stored in a multi-dimensional linked list.
// That is, a linked list (rows) of linked lists (row values)
// Results are composed of rows. Rows are composed of cells.
struct
cell_node
{
void
*
value
;
int
type
;
struct
cell_node
*
next
;
};
struct
row_node
{
struct
cell_node
*
cells
;
struct
row_node
*
next
;
};
struct
fetchall_request
{
Persistent
<
Function
>
cb
;
Statement
*
sto
;
...
...
@@ -150,10 +151,4 @@ struct fetchall_request {
struct
row_node
*
rows
;
};
// represent strings with this struct
struct
string_t
{
size_t
bytes
;
char
data
[];
};
#endif
tests/old/speedtest.js
View file @
aefb3cc4
var
fs
=
require
(
"fs"
),
sys
=
require
(
"sys"
),
sqlite
=
require
(
"
../
sqlite"
);
sqlite
=
require
(
"sqlite"
);
var
puts
=
sys
.
puts
;
var
inspect
=
sys
.
inspect
;
...
...
tests/test-statement-step.js
View file @
aefb3cc4
...
...
@@ -25,14 +25,14 @@ function createTestTable(db, callback) {
var
testRows
=
[
[
1
,
"foo"
,
9
]
,
[
2
,
"bar"
,
8
]
,
[
3
,
"baz"
,
7
]
,
[
3
,
null
,
7
]
,
[
4
,
"quux"
,
6
]
,
[
5
,
"juju"
,
5
]
,
[
5
,
"juju"
,
null
]
];
var
testRowsExpected
=
[
{
id
:
5
,
name
:
'juju'
,
age
:
5
}
var
testRowsExpected
=
[
{
id
:
5
,
name
:
'juju'
,
age
:
null
}
,
{
id
:
4
,
name
:
'quux'
,
age
:
6
}
,
{
id
:
3
,
name
:
'baz'
,
age
:
7
}
,
{
id
:
3
,
name
:
null
,
age
:
7
}
,
{
id
:
2
,
name
:
'bar'
,
age
:
8
}
,
{
id
:
1
,
name
:
'foo'
,
age
:
9
}
];
...
...
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