Commit Graph

216 Commits

Author SHA1 Message Date
Yasuhiro Matsumoto d1009b4fa6 fix build 2016-11-08 17:12:03 +09:00
Yasuhiro Matsumoto bfeda3f4f6 fix build 2016-11-08 17:07:52 +09:00
Yasuhiro Matsumoto ea2afbe9e8 revert Multiple Result Set 2016-11-08 13:22:46 +09:00
Yasuhiro Matsumoto dc448a0cb6 fix trace callback. 2016-11-08 12:27:31 +09:00
Yasuhiro Matsumoto dd2c82226b fix trace callback.
Close #352
2016-11-08 12:19:51 +09:00
andrefsp 6c0a6bb9cd Fix data race introduced on 605d9d08
This commit will fix a data race introduced on 605d9d08 and also
make sure travis CI will now check for data races.
2016-11-07 11:57:52 +00:00
Yasuhiro Matsumoto deed33aec7 cancel 2016-11-06 20:46:27 +09:00
Yasuhiro Matsumoto 605d9d0851 cancel 2016-11-06 20:43:53 +09:00
Yasuhiro Matsumoto 0d1d1a644e go vet && golint 2016-11-05 00:40:06 +09:00
Yasuhiro Matsumoto 755d5be32c add BeginContext 2016-11-04 15:15:16 +09:00
Yasuhiro Matsumoto 025b917610 add PrepareContext 2016-11-04 15:11:24 +09:00
Yasuhiro Matsumoto b23526fb3c support named params 2016-11-04 15:00:29 +09:00
Yasuhiro Matsumoto c95a77965c context features 2016-11-04 14:24:22 +09:00
Yasuhiro Matsumoto 86681de00a remove -Wno-c99-extension
Close #343
2016-10-28 23:22:18 +09:00
Judson 61c9552d18
Added CFLAG config to ignore deprecations 2016-10-04 16:51:54 +01:00
Yasuhiro Matsumoto bf2cfc371a fix build 2016-09-08 00:59:25 +09:00
Yasuhiro Matsumoto 467e3720d8 fix build 2016-09-08 00:39:47 +09:00
A.N 0a2fcd29b6 Provide access to sqlite3_trace_v2(). 2016-09-07 23:48:06 +09:00
mattn e118d44513 Merge pull request #300 from sqweek/issue184
Fix inconsistent tx state with database/sql.
2016-07-15 22:38:49 +09:00
Zbigniew Mandziejewicz 3ebb821e65 Set SQLITE_DETERMINISTIC if undefined 2016-04-23 00:00:49 +08:00
sqweek 727ad200a2 Fix inconsistent tx state with database/sql.
The semantics of sql.Tx.Commit impose that the transaction is
finished and cleaned up by the time the driver's Commit function
returns. However sqlite3 leaves the transaction open if COMMIT
fails due to an SQLITE_BUSY error, so *we* must clean it up.

Closes #184.
2016-04-18 21:47:24 +08:00
David Bariod 3a5555302e Move sqlite3 amalgation files a directory up.
The purpose is to ease the use of vendoring files like godep.
The C sqlite3 files have been added a go compilation conditional flag
Fix #293
2016-04-02 12:48:26 +02:00
Zac Medico f544db98cc Add SQLiteRows.DeclTypes() method 2016-03-06 12:27:17 -08:00
Philip O Toole 1e280555b7 Fix minor typos in comments 2016-02-23 01:26:13 -05:00
mattn c5aee96497 Merge pull request #267 from ianlancetaylor/go16
bind: pass &v[0] in direct call to C
2016-02-01 14:34:37 +09:00
Ian Lance Taylor 8c66b9cf5e callback: use handles rather than passing Go pointers
The cgo pointer passing rules forbid passing a Go pointer to C if that
pointer points to memory containing other Go pointers.  This is true
even if the Go pointer is converted to uintptr.

This change fixes the code to use a handle instead, and to look up the
handle in the callback function.
2016-01-29 13:18:39 -08:00
Ian Lance Taylor b76c61051f bind: pass &v[0] in direct call to C
In Go 1.6, the cgo checking rules are more precise when they see an
address operation as an argument to the C function.  When you pass &v[0]
to a C function, the cgo check just verifies that v itself does not
contain any pointers.  When you write `p := &v[0]` and then pass p to
the C function, the cgo check is conservative: it verifies that the
entire memory block to which p points does not contain any pointers.
When the bind function is called by code that passes a slice that is
part of a larger struct, this means that the cgo check will look at the
entire larger struct, not just the slice.  This can cause a surprising
run time failure.

Avoid this problem by rewriting the code slightly to pass &v[0] in the
call to the C function itself.

In particular this fixes the tests of github.com/jmoiron/sqlx when using
Go 1.6.
2016-01-29 12:39:47 -08:00
Yasuhiro Matsumoto e969434e25 avoid cgoCheckPointer. ref https://github.com/golang/go/issues/12416 2015-12-30 23:29:15 +09:00
Yasuhiro Matsumoto a755cdc361 Merge branch 'master' of https://github.com/mattn/go-sqlite3 2015-11-02 11:56:57 +09:00
Yasuhiro Matsumoto 167173a31f Merge branch 'pr/207' 2015-11-02 11:53:42 +09:00
Augusto Roman 7b0d180ce9 Store/retrieve timezones for time.Time values.
Previously, the timezone information for a provided value was discarded
and the value always stored as in UTC.  However, sqlite allows specifying
the timezone offsets and handles those values appropriately.  This change
stores the timezone information and parses it out if present, otherwise
it defaults to UTC as before.

One additional bugfix:  Previously, a unix timestamp in seconds was
parsed in the local timezone (rather than UTC), in contrast to a unix
timestamp in milliseconds that was parsed in UTC.

While fixing that extra bug, I cleaned up the parsing code -- no need to
convert to a string and then parse it back again and risk a parse error,
just to check the number of digits.

The tests were extended to cover non-UTC timezones storage & retrieval,
meaningful unix timestamps, and correct handling of a trailing Z.
2015-10-09 22:59:25 -07:00
looi b808f01f66 Add FTS4 unicode61 tokenizer support 2015-09-21 19:53:44 +09:00
mattn 0bb7f1c676 Merge pull request #229 from danderson/master
Implement support for calling Go functions from SQLite
2015-09-16 10:46:17 +09:00
David Anderson 26917df7a6 Implement support for aggregation functions implemented in Go. 2015-09-15 18:05:49 -07:00
Jessica Frazelle e37121d4ea introduce ability to pass sqlite_omit_load_extension
sqlite_omit_load_extension is a go build tag which behaves much like its
C counterpart SQLITE_OMIT_LOAD_EXTENSION

Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2015-09-04 14:46:16 -07:00
David Anderson b037a61690 Add support for interface{} arguments in Go SQLite functions.
This enabled support for functions like Foo(a interface{}) and
Bar(a ...interface{}).
2015-08-21 17:12:18 -07:00
David Anderson 566f63a43a Implement support for variadic functions.
Currently, the variadic part must all be the same type, because there's
no "generic" arg converter.
2015-08-21 16:38:23 -07:00
David Anderson 122ddb16de Move argument converters to callback.go, and optimize return value handling.
A call now doesn't have to do any reflection, it just blindly invokes
a bunch of argument and return value handlers to execute the translation,
and the safety of the translation is determined at registration time.
2015-08-21 16:37:45 -07:00
David Anderson cf8fa0af80 Implement support for passing Go functions as custom functions to SQLite.
Fixes #226.
2015-08-21 13:39:50 -07:00
kiwih 6b4ee3cb4f Add fix for go-sqlite3 truncating 64-bit integers when compiled by 32-bit mingw-gcc on windows by converting 'long' variable types to 'long long' in sqlite3.go 2015-08-07 15:13:52 +12:00
Lars Buitinck 90505effc7 Fix doc comment 2015-06-05 16:38:51 +02:00
Yasuhiro Matsumoto dee1a37fe1 Z suffix should be no-op 2015-04-15 16:26:27 +09:00
mattn 5f64400729 Merge pull request #194 from hallyn/tximm.2
Add a txlock option when opening databases
2015-04-14 09:12:54 +09:00
Serge Hallyn f91a09fb50 Add a txlock option when opening databases (v2)
When specified, changes the default locking at a tx.Begin.

Changelog (v2):
	Add a testcase to ensure _txlock is properly handled.

Closes #189

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2015-04-13 11:48:01 -05:00
Egon Elbre ac0129617f Fix NULs in text.
NUL character is a valid symbols in UTF8.

Fixes #195
2015-04-12 15:02:50 +03:00
mattn e28cd440fa Merge pull request #188 from larsmans/optimize
Optimize queries
2015-03-24 08:48:55 +09:00
Lars Buitinck 4dfb2ecaf0 Change strlen(s) > 0 => *s != '\000'. 2015-03-23 22:18:23 +01:00
Lars Buitinck 92b704c1a6 Less C/Go border crossing to get database changes
Speeds up the query benchmark by about 5% (Go 1.2.1, Linux x64).
2015-03-23 22:17:00 +01:00
mattn 07f9c9c30f Implement number-named parameters. Close #187 2015-03-24 00:46:49 +09:00
mattn ff38c8ec02 Revert a6c208564e 2015-03-22 04:29:14 +09:00
mattn e3990c31a0 Remove debug message 2015-03-22 03:38:57 +09:00
mattn 1354684d2b Fix hang in test 2015-03-22 03:37:43 +09:00
mattn c1abf95b38 Fix build 2015-03-22 03:16:35 +09:00
mattn fcd455919e Should use C.int() 2015-03-22 03:11:25 +09:00
mattn d754d2db45 revert 5253daf856 and add _busy_timeout query parameter. 2015-03-22 03:02:03 +09:00
mattn a6c208564e Support $NNN-style named parameter. Close #187 2015-03-22 02:08:47 +09:00
mattn 5253daf856 Next() should wait while BUSY or LOCKED because return value is bool 2015-03-19 13:29:43 +09:00
Yasuhiro Matsumoto 308067797b Apply -lpthread withou windows. 2015-03-12 18:43:55 +09:00
Stéphane Graber e688f0a8eb Link against pthread
This is required by gccgo because of the pthread_mutex_trylock symbol.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2015-03-11 16:20:52 -04:00
Stéphane Graber 3d6c6f9345 Rename sqlite3.{c,h} to sqlite3-binding.{c,h}
This fixes the problem where when building with gccgo, sqlite3.c is
overwritten, leading to a build failure.

An alternative would have been to move sqlite3*.{c,h} to a subdirectory,
but that seems to confuse the linker a fair bit and would just swap one
implementation-dependent issue for another.

Closes #20

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2015-03-11 16:19:50 -04:00
Antoni Rościszewski 16f5b6415d Correct HasPrefix method name 2015-03-05 18:23:57 +01:00
mattn 519a1d07c4 Don't modify dsn when has prefix file: 2015-03-06 02:00:09 +09:00
Yasuhiro Matsumoto d86face730 Fix filename with loc parameter 2015-03-05 12:49:22 +09:00
mix3 e48e0597ab Fix loc parsing 2015-03-05 11:06:33 +09:00
mattn e273a1552e Fixed bug for loc parameter 2015-03-05 01:17:38 +09:00
Yasuhiro Matsumoto 18aa166fa9 cleanup code 2015-03-04 22:58:32 +09:00
Yasuhiro Matsumoto 4c5c4e5261 Add loc=XXX parameters to handle timezone 2015-03-04 22:49:17 +09:00
Yasuhiro Matsumoto da2bf8a0f3 Add FTS3 feature. Close #176 2015-02-24 11:28:02 +09:00
Attila Tajti 0486deea0d load extensions using the C API instead of SQL
This fixes the problem of loading ICU, which needs to replace existing
functions. Replacing existing functions are prohibited when a VM
is running.
2015-01-26 16:50:50 +01:00
Mahadevan a14f442f3e Return error code of sqlite3_step, not sqlite3_reset 2015-01-26 14:10:18 +05:30
Ian Bishop 0b05acc293 Handle 13 digit datetime values 2015-01-02 16:42:25 +10:00
Nahum Shalman ae251919bd set CFLAGS: -std=gnu99
Fixes the following error message on SmartOS:

$ go get github.com/mattn/go-sqlite3
In file included from /usr/include/stdio.h:37:0,
                 from go/src/github.com/mattn/go-sqlite3/sqlite3.c:8422:
/opt/local/gcc47/lib/gcc/i386-sun-solaris2.11/4.7.3/include-fixed/sys/feature_tests.h:366:2: error: #error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications  require the use of c99"
2014-12-18 17:16:42 -05:00
Josiah Kiehl (formerly @bluepojo) 3dc340b45f Catch missing arguments for Query()
Also improved error message on Exec() for consistency.
2014-11-29 14:08:02 -08:00
mattn d10e2c8f62 Reset statement. Fixes #150 2014-11-16 23:51:46 +09:00
mattn e63d2546a0 set/reset finalizer to free SQLite3 handles 2014-11-14 17:13:35 +09:00
mattn 12a1c0f435 rows.Close() 2014-11-14 02:21:49 +09:00
mattn e5819757da Should affect on only 386 2014-10-24 19:38:05 +09:00
mattn c1aa7ac706 Merge pull request #155 from kartaca/master
fixed timezone problem for datetime types
2014-10-24 18:22:46 +09:00
Mehmet Gurevin 6710e996b5 fixed timezone problem for datetime types 2014-10-23 20:12:32 +03:00
mattn 00716954b7 Specify by -D 2014-10-22 13:31:54 +09:00
mattn 1fbcb3cdc2 Thread safe 2014-10-20 15:19:03 +09:00
romo 86932b40b0 add Version func for retrieving SQLite library version info 2014-10-13 11:05:49 +09:00
mattn a80c27ba33 Merge commit '3d78a08b9f3307ac3874f5c120f7d4166c62efb9' 2014-09-10 15:02:09 +09:00
mattn 3d78a08b9f Workaround for #109, #147 2014-09-10 14:58:32 +09:00
mattn 3ab1d6f348 Merge branch 'master' of https://github.com/mattn/go-sqlite3 2014-09-03 09:21:35 +09:00
mattn 0a0c543dc0 Merge branch 'pr/135' 2014-09-03 09:21:15 +09:00
Peter Waller 764e046d89 Add "date" to decltypes parsed as a unix time 2014-09-02 16:36:34 +01:00
mattn 72cb8db627 Fixed checking parameter count 2014-08-18 18:48:48 +09:00
mattn b718c29aea Merge branch 'master' of github.com:mattn/go-sqlite3 2014-08-18 18:24:12 +09:00
mattn d069822191 Check parameter count 2014-08-18 18:23:58 +09:00
mattn 6535341da9 Add one blank line for godoc 2014-08-18 17:00:59 +09:00
mattn 5e5d088a36 Add license header 2014-08-18 16:56:31 +09:00
Peter Waller ff0960b999 Add 'date' to rc.decltypes interpreted as a time 2014-08-11 11:03:27 +01:00
Sven Engelhardt deaffef7cb implicitly close Stmt in Queryer, Close #131
the cls field tracks if the Stmt should be implicitly closed, in the
Exec() call the generated statement is always closed
2014-07-15 18:13:47 +02:00
Sean Duffy d444acb5da Add missing time format, fixes #43 2014-07-08 10:56:44 +01:00
mattn d9e7576acf Fix error on Execer. Close #124 2014-06-26 03:54:30 +09:00
mattn d56eb93ecb Implements Execer/Queryer. Close #60, #82, #113 2014-06-25 11:41:58 +09:00
mattn a59fbb40eb Merge pull request #116 from c14n/master
Enable extended error codes.
2014-06-25 11:34:13 +09:00
mattn f7d2df0102 Remove dead code in SQLiteRows.Bind. Close #119 2014-06-25 11:30:31 +09:00
Christoph Martin f395aa170e Enable extended error codes. 2014-04-01 14:01:19 +02:00