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
180dde44
Commit
180dde44
authored
Jun 22, 2011
by
Konstantin Käfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add busyTimeout and set default busy timeout to 1 second
parent
26835aca
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
database.cc
src/database.cc
+25
-0
database.h
src/database.h
+2
-0
No files found.
src/database.cc
View file @
180dde44
...
@@ -157,6 +157,10 @@ int Database::EIO_Open(eio_req *req) {
...
@@ -157,6 +157,10 @@ int Database::EIO_Open(eio_req *req) {
sqlite3_close
(
db
->
handle
);
sqlite3_close
(
db
->
handle
);
db
->
handle
=
NULL
;
db
->
handle
=
NULL
;
}
}
else
{
// Set default database handle values.
sqlite3_busy_timeout
(
db
->
handle
,
1000
);
}
return
0
;
return
0
;
}
}
...
@@ -324,6 +328,17 @@ Handle<Value> Database::Configure(const Arguments& args) {
...
@@ -324,6 +328,17 @@ Handle<Value> Database::Configure(const Arguments& args) {
Baton
*
baton
=
new
Baton
(
db
,
handle
);
Baton
*
baton
=
new
Baton
(
db
,
handle
);
db
->
Schedule
(
RegisterProfileCallback
,
baton
);
db
->
Schedule
(
RegisterProfileCallback
,
baton
);
}
}
else
if
(
args
[
0
]
->
Equals
(
String
::
NewSymbol
(
"busyTimeout"
)))
{
if
(
!
args
[
1
]
->
IsInt32
())
{
return
ThrowException
(
Exception
::
TypeError
(
String
::
New
(
"Value must be an integer"
))
);
}
Local
<
Function
>
handle
;
Baton
*
baton
=
new
Baton
(
db
,
handle
);
baton
->
status
=
args
[
1
]
->
Int32Value
();
db
->
Schedule
(
SetBusyTimeout
,
baton
);
}
else
{
else
{
return
ThrowException
(
Exception
::
Error
(
String
::
Concat
(
return
ThrowException
(
Exception
::
Error
(
String
::
Concat
(
args
[
0
]
->
ToString
(),
args
[
0
]
->
ToString
(),
...
@@ -336,6 +351,16 @@ Handle<Value> Database::Configure(const Arguments& args) {
...
@@ -336,6 +351,16 @@ Handle<Value> Database::Configure(const Arguments& args) {
return
args
.
This
();
return
args
.
This
();
}
}
void
Database
::
SetBusyTimeout
(
Baton
*
baton
)
{
assert
(
baton
->
db
->
open
);
assert
(
baton
->
db
->
handle
);
// Abuse the status field for passing the timeout.
sqlite3_busy_timeout
(
baton
->
db
->
handle
,
baton
->
status
);
delete
baton
;
}
void
Database
::
RegisterTraceCallback
(
Baton
*
baton
)
{
void
Database
::
RegisterTraceCallback
(
Baton
*
baton
)
{
assert
(
baton
->
db
->
open
);
assert
(
baton
->
db
->
open
);
assert
(
baton
->
db
->
handle
);
assert
(
baton
->
db
->
handle
);
...
...
src/database.h
View file @
180dde44
...
@@ -149,6 +149,8 @@ protected:
...
@@ -149,6 +149,8 @@ protected:
static
Handle
<
Value
>
Configure
(
const
Arguments
&
args
);
static
Handle
<
Value
>
Configure
(
const
Arguments
&
args
);
static
void
SetBusyTimeout
(
Baton
*
baton
);
static
void
RegisterTraceCallback
(
Baton
*
baton
);
static
void
RegisterTraceCallback
(
Baton
*
baton
);
static
void
TraceCallback
(
void
*
db
,
const
char
*
sql
);
static
void
TraceCallback
(
void
*
db
,
const
char
*
sql
);
static
void
TraceCallback
(
Database
*
db
,
std
::
string
*
sql
);
static
void
TraceCallback
(
Database
*
db
,
std
::
string
*
sql
);
...
...
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