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
989f5a6b
Commit
989f5a6b
authored
Mar 17, 2010
by
Orlando Vazquez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small perf tweaks
parent
e631a8e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
18 deletions
+22
-18
sqlite3_bindings.cc
sqlite3_bindings.cc
+21
-17
test3.js
test3.js
+1
-1
No files found.
sqlite3_bindings.cc
View file @
989f5a6b
...
...
@@ -81,8 +81,8 @@ public:
NODE_SET_PROTOTYPE_METHOD
(
t
,
"open"
,
Open
);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"close"
,
Close
);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"changes"
,
Changes
);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"lastInsertRowid"
,
LastInsertRowid
);
//
NODE_SET_PROTOTYPE_METHOD(t, "changes", Changes);
//
NODE_SET_PROTOTYPE_METHOD(t, "lastInsertRowid", LastInsertRowid);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"prepare"
,
Prepare
);
target
->
Set
(
v8
::
String
::
NewSymbol
(
"Database"
),
t
->
GetFunction
());
...
...
@@ -420,10 +420,10 @@ protected:
t
->
InstanceTemplate
()
->
SetInternalFieldCount
(
1
);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"bind"
,
Bind
);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"clearBindings"
,
ClearBindings
);
//
NODE_SET_PROTOTYPE_METHOD(t, "clearBindings", ClearBindings);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"finalize"
,
Finalize
);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"bindParameterCount"
,
BindParameterCount
);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"reset"
,
Reset
);
//
NODE_SET_PROTOTYPE_METHOD(t, "bindParameterCount", BindParameterCount);
//
NODE_SET_PROTOTYPE_METHOD(t, "reset", Reset);
NODE_SET_PROTOTYPE_METHOD
(
t
,
"step"
,
Step
);
//target->Set(v8::String::NewSymbol("SQLStatement"), t->GetFunction());
...
...
@@ -434,14 +434,14 @@ protected:
int
I
=
0
;
REQ_EXT_ARG
(
0
,
stmt
);
(
new
Statement
((
sqlite3_stmt
*
)
stmt
->
Value
()))
->
Wrap
(
args
.
This
());
return
args
.
This
();
}
protected
:
Statement
(
sqlite3_stmt
*
stmt
)
:
stmt_
(
stmt
)
{}
~
Statement
()
{
if
(
stmt_
)
sqlite3_finalize
(
stmt_
);
}
~
Statement
()
{
if
(
stmt_
)
{
sqlite3_finalize
(
stmt_
);
}
}
sqlite3_stmt
*
stmt_
;
operator
sqlite3_stmt
*
()
const
{
return
stmt_
;
}
...
...
@@ -804,9 +804,12 @@ protected:
}
step_req
->
cb
.
Dispose
();
free
(
step_req
->
column_data
);
free
(
step_req
->
column_types
);
free
(
step_req
->
column_names
);
if
(
step_req
->
column_count
)
{
free
(
step_req
->
column_data
);
free
(
step_req
->
column_types
);
free
(
step_req
->
column_names
);
}
free
(
step_req
);
...
...
@@ -823,13 +826,14 @@ protected:
if
(
rc
==
SQLITE_ROW
)
{
// would be nice to cache the column names and type data somewhere
step_req
->
column_count
=
sqlite3_column_count
(
stmt
);
step_req
->
column_types
=
(
int
*
)
calloc
(
step_req
->
column_count
,
sizeof
(
int
));
step_req
->
column_data
=
(
void
**
)
calloc
(
step_req
->
column_count
,
sizeof
(
void
*
));
step_req
->
column_names
=
(
char
**
)
calloc
(
step_req
->
column_count
,
sizeof
(
char
*
));
if
(
step_req
->
column_count
=
sqlite3_column_count
(
stmt
))
{
step_req
->
column_types
=
(
int
*
)
calloc
(
step_req
->
column_count
,
sizeof
(
int
));
step_req
->
column_data
=
(
void
**
)
calloc
(
step_req
->
column_count
,
sizeof
(
void
*
));
step_req
->
column_names
=
(
char
**
)
calloc
(
step_req
->
column_count
,
sizeof
(
char
*
));
}
for
(
int
i
=
0
;
i
<
step_req
->
column_count
;
i
++
)
{
int
type
=
step_req
->
column_types
[
i
]
=
sqlite3_column_type
(
stmt
,
i
);
...
...
test3.js
View file @
989f5a6b
...
...
@@ -28,7 +28,7 @@ function writeTest(db, callback) {
function
innerFunction
()
{
db
.
query
(
"INSERT INTO t1 VALUES (1)"
,
function
(
row
)
{
if
(
!
i
--
&&
!
row
)
{
if
(
!
i
--
)
{
// end of results
var
dt
=
((
new
Date
)
-
t0
)
/
1000
;
puts
(
"**** "
+
count
+
" insertions in "
+
dt
+
"s ("
+
(
count
/
dt
)
+
"/s)"
);
...
...
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