Commit Graph

216 Commits

Author SHA1 Message Date
Kirill Smelkov f675967c54 Let SQLite use pread/pwrite
With current settings SQLite was using lseek/read syscalls to read data, e.g.:

	20:43:17.640660 fcntl(3, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
	20:43:17.640683 fcntl(3, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
	20:43:17.640705 fcntl(3, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = 0
	20:43:17.640725 fcntl(3, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
	20:43:17.640744 stat(".../neo.sqlite-journal", 0x7ffef2c91080) = -1 ENOENT (No such file or directory)
	20:43:17.640764 lseek(3, 24, SEEK_SET)  = 24
	20:43:17.640779 read(3, "\0\0\0\33\0\0\10\235\0\0\10]\0\0\0\27", 16) = 16
	20:43:17.640795 stat(".../neo.sqlite-wal", 0x7ffef2c91080) = -1 ENOENT (No such file or directory)

but if we allow it to use pread it will be only 1 system call instead of 2 and
reading this way can also be done in parallel because there is no global to
file seeking:

	20:48:42.668466 fcntl(3, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
	20:48:42.668501 fcntl(3, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
	20:48:42.668522 fcntl(3, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = 0
	20:48:42.668542 fcntl(3, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
	20:48:42.668561 stat(".../neo.sqlite-journal", 0x7ffdbc1f22c0) = -1 ENOENT (No such file or directory)
	20:48:42.668580 pread64(3, "\0\0\0\33\0\0\10\235\0\0\10]\0\0\0\27", 16, 24) = 16
	20:48:42.668597 stat(".../neo.sqlite-wal", 0x7ffdbc1f22c0) = -1 ENOENT (No such file or directory)

(if needed this enablement can be done per OS)
2018-02-16 20:44:19 +03:00
mattn 534c0213e2
Merge pull request #525 from mattn/add-usleep
add -DHAVE_USLEEP=1
2018-02-07 18:32:28 +09:00
Yasuhiro Matsumoto f84a0f6cbe add -DHAVE_USLEEP=1
fixes #211
2018-02-07 17:16:12 +09:00
James C Kimble 614d7c1fda
Add static_mock.go to allow building with CGO_ENABLED=0 2018-01-31 22:24:37 -06:00
mattn 6c771bb988
Merge pull request #462 from faruzzy/master
Updated "context" import since it has become a standard library
2018-01-12 17:58:26 +09:00
Niklas Janlert 58004848f1 Fix race in ExecContext
When the context is cancelled, an interrupt should only be made if the
operation is still ongoing.
2017-11-21 13:40:00 +01:00
mattn ed69081a91
Merge pull request #479 from kenshaw/move-registeraggregator
Move RegisterAggregator implementation
2017-11-14 17:56:34 +09:00
Tetsuya Morimoto 9dddfd1328 fix to be able to build with GOTAGS=libsqlite3 2017-11-05 20:01:16 +09:00
Tetsuya Morimoto b07b06e15c update to call _sqlite3_limit as a wrapper instead of sqlite3_limit 2017-11-05 19:45:38 +09:00
Kenneth Shaw 7174000f77 Move RegisterAggregator implementation
The SQLiteConn.RegisterAggregator implementation was defined in
sqlite3_trace.go file, which is guarded with a build constraint. This
change simply moves RegisterAggregator to the main sqlite3.go file,
and moves accompanying unit tests.

The rationale for this move is that it was not possible for downstream
using packages to use RegisterAggregator without also specifying (and
notifying the user) the 'trace' build tag.
2017-11-05 09:18:06 +07:00
Tetsuya Morimoto d785b8f812 support sqlite3_limit to get/set run time limit 2017-11-05 08:19:06 +09:00
Roland Pangu 5df314a2dc Updated "context" import since it has become a standard library after go 1.7 https://golang.org/doc/go1.7#context 2017-09-05 19:54:16 -07:00
mattn 132eeedb4a Merge branch 'master' into master 2017-08-30 19:57:18 +09:00
Yasuhiro Matsumoto 8d81c2f1f8 fix race 2017-08-30 19:37:57 +09:00
Yasuhiro Matsumoto 58ed4a0810 fix race 2017-08-30 19:30:53 +09:00
Yasuhiro Matsumoto 911f1c4fa6 fix lock 2017-08-30 19:27:02 +09:00
Yasuhiro Matsumoto d40d490543 fixes #458 2017-08-28 18:58:02 +09:00
Greg Holt 85e456ef27 Fix to pass TestNilAndEmptyBytes 2017-08-21 13:30:07 -07:00
Yasuhiro Matsumoto 1828334c4a remove mutex 2017-08-02 01:43:14 +09:00
Yasuhiro Matsumoto 569232dc08 fix possibly double Close.
fixes #448
2017-08-02 00:06:18 +09:00
Ross Light 848386d7a2 Add connection option for recursive triggers
Similar to foreign keys, the recursive triggers PRAGMA affects the
interpretation of all statements on a connection.
2017-07-09 07:32:14 -07:00
Jason Abbott 0644414997 Merge pull request #2 from mattn/master
Merge lastest from mattn
2017-07-06 11:52:32 -06:00
Yasuhiro Matsumoto acfa601240 SQLITE_THREADSAFE=1
fixes #274
2017-07-05 17:25:24 +09:00
Jason Abbott 59bd281a89 Incorporate original PR 271 from https://github.com/brokensandals 2017-07-03 12:51:48 -06:00
deepilla 05123859be Don't convert Unix times to nanoseconds when querying datetime fields. Fixes #430. 2017-06-30 13:17:04 -05:00
Evgeniy Makeev ef9f773b24 Fix for cgo panic, issue #428: https://github.com/mattn/go-sqlite3/issues/428 2017-06-20 17:36:44 -07:00
Philip O'Toole cd1cbf523a Sync database-close and statement-close
Potential fix for issue #426.
2017-06-17 12:26:06 -07:00
Xu Xinran 3fa7ed2176 Use global variable for better performance. 2017-06-14 21:22:40 +08:00
Xu Xinran 308f5f1b2f Treat []byte{} as empty bytes instead of NULL. 2017-06-14 19:55:09 +08:00
David Anderson 0430b37250 Add support for collation sequences implemented in Go.
This allows Go programs to register custom comparison functions with
sqlite, and ORDER BY that comparator.
2017-06-08 19:14:07 -07:00
mattn 46e826d22a Merge pull request #407 from zombiezen/foreignkeys
Add _foreign_keys connection parameter
2017-04-02 23:13:39 +09:00
Ross Light c6d43c40e6 Add _foreign_keys connection parameter
Fixes #377
Updates #255
2017-04-01 11:06:59 -07:00
Ross Light 4c2dc8806a Avoid leaking db if setting busy timeout fails 2017-04-01 08:53:17 -07:00
Marko Kungla a1253acb6b
Removed ambitious conn.Close() 2017-03-24 01:06:55 +01:00
Yasuhiro Matsumoto fc03fa9989 close connection when got errors in Open 2017-03-24 08:48:29 +09:00
Yasuhiro Matsumoto 866c3293d9 fix breaking compatibility.
revert cf4bd560f1

close #394
2017-03-21 09:14:48 +09:00
Yasuhiro Matsumoto 0acd8f7aec fix build 2017-03-20 23:34:57 +09:00
Yasuhiro Matsumoto 997cab8094 fix build 2017-03-20 23:31:22 +09:00
Yasuhiro Matsumoto cf4bd560f1 fix build 2017-03-20 23:26:15 +09:00
Yasuhiro Matsumoto 53900fb4f0 return nil when last error is SQLITE_OK 2017-03-20 23:23:24 +09:00
Yasuhiro Matsumoto 32ab0d8730 refactoring 2017-03-05 22:16:51 +09:00
Conor Branagan bba480975b Add Go API for virtual tables
See https://www.sqlite.org/vtab.html for more details.

This work was started from
https://github.com/gwenn/gosqlite/blob/master/vtab.{c,go} and adds:

- Porting the API to go-sqlite3 APIs.
- Support for >= Go 1.6 without requiring the `cgocheck` flag to be changed.
- Filling out the unfinished callback functions for the `Vtable` struct.
- A simple `Context` API layer for ease of use when adding modules.

Tests are included.
2017-03-04 18:10:02 -05:00
Yasuhiro Matsumoto 253bbf431d rename function 2017-03-05 00:45:41 +09:00
Yasuhiro Matsumoto a7b54c9ddb workaround for a compiler
Apple LLVM version 7.0.2 (clang-700.1.81)

Close #386
2017-03-01 16:44:54 +09:00
Yasuhiro Matsumoto 2acfafad58 use variable db 2017-02-16 15:57:29 +09:00
Yasuhiro Matsumoto 588cd3292b fixes race 2017-02-11 21:48:33 +09:00
Yasuhiro Matsumoto a554cf198f close statement 2017-01-07 22:22:02 +09:00
Yasuhiro Matsumoto 6f2749a3ca fix race condition 2017-01-03 22:25:02 +09:00
Yasuhiro Matsumoto 056f235aa6 fix named args 2016-12-09 13:12:14 +09:00
Yasuhiro Matsumoto f043f8092b use prepare instead of Prepare 2016-11-09 01:13:34 +09:00