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
800c61fb
Commit
800c61fb
authored
Mar 17, 2011
by
Konstantin Käfer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finalize the statement when the database was closed intermittently
parent
013d9ae3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
2 deletions
+66
-2
database.h
src/database.h
+1
-1
statement.h
src/statement.h
+6
-1
scheduling.test.js
test/scheduling.test.js
+59
-0
No files found.
src/database.h
View file @
800c61fb
...
@@ -41,7 +41,7 @@ public:
...
@@ -41,7 +41,7 @@ public:
ev_ref
(
EV_DEFAULT_UC
);
ev_ref
(
EV_DEFAULT_UC
);
callback
=
Persistent
<
Function
>::
New
(
cb_
);
callback
=
Persistent
<
Function
>::
New
(
cb_
);
}
}
~
Baton
()
{
virtual
~
Baton
()
{
db
->
Unref
();
db
->
Unref
();
ev_unref
(
EV_DEFAULT_UC
);
ev_unref
(
EV_DEFAULT_UC
);
callback
.
Dispose
();
callback
.
Dispose
();
...
...
src/statement.h
View file @
800c61fb
...
@@ -132,8 +132,13 @@ public:
...
@@ -132,8 +132,13 @@ public:
Baton
(
db_
,
cb_
),
stmt
(
stmt_
)
{
Baton
(
db_
,
cb_
),
stmt
(
stmt_
)
{
stmt
->
Ref
();
stmt
->
Ref
();
}
}
~
PrepareBaton
()
{
virtual
~
PrepareBaton
()
{
stmt
->
Unref
();
stmt
->
Unref
();
if
(
!
db
->
open
&&
db
->
locked
)
{
// The database handle was closed before the statement could be
// prepared.
stmt
->
Finalize
();
}
}
}
};
};
...
...
test/scheduling.test.js
0 → 100644
View file @
800c61fb
var
sqlite3
=
require
(
'sqlite3'
);
var
assert
=
require
(
'assert'
);
if
(
process
.
setMaxListeners
)
process
.
setMaxListeners
(
0
);
exports
[
'test scheduling a query after the database was closed'
]
=
function
(
beforeExit
)
{
var
error
=
false
;
var
db
=
new
sqlite3
.
Database
(
':memory:'
);
db
.
on
(
'error'
,
function
(
err
)
{
error
=
true
;
assert
.
equal
(
err
.
message
,
"SQLITE_MISUSE: Database handle is closed"
);
});
db
.
close
();
db
.
run
(
"CREATE TABLE foo (id int)"
);
beforeExit
(
function
()
{
assert
.
ok
(
error
);
});
};
exports
[
'test scheduling a query with callback after the database was closed'
]
=
function
(
beforeExit
)
{
var
error
=
false
;
var
errorEvent
=
false
;
var
db
=
new
sqlite3
.
Database
(
':memory:'
);
db
.
on
(
'error'
,
function
(
err
)
{
errorEvent
=
true
;
});
db
.
close
();
db
.
run
(
"CREATE TABLE foo (id int)"
,
function
(
err
)
{
assert
.
ok
(
err
.
message
,
"SQLITE_MISUSE: Database handle is closed"
);
error
=
true
;
});
beforeExit
(
function
()
{
assert
.
ok
(
error
);
assert
.
ok
(
!
errorEvent
);
});
};
exports
[
'test running a query after the database was closed'
]
=
function
(
beforeExit
)
{
var
error
=
false
;
var
db
=
new
sqlite3
.
Database
(
':memory:'
);
db
.
on
(
'error'
,
function
(
err
)
{
error
=
true
;
assert
.
equal
(
err
.
message
,
"SQLITE_BUSY: unable to close due to unfinalised statements"
);
});
var
stmt
=
db
.
prepare
(
"CREATE TABLE foo (id int)"
);
db
.
close
();
stmt
.
run
();
beforeExit
(
function
()
{
assert
.
ok
(
error
);
});
};
\ No newline at end of file
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