Commit Graph

323 Commits (a0963d8f2259b9c7f291887979d9dac2441b4ca6)

Author SHA1 Message Date
Ben Johnson 2bc868c466 Merge pull request #88 from benbjohnson/tx-rename
Make DB/Tx API more consistent.
2014-03-24 11:46:58 -06:00
Ben Johnson f8ad21bad3 Make DB/Tx API more consistent.
I consolidated the DB.Tx() and DB.RWTx() calls into a single
DB.Begin(writable bool) call. This is more consistent with the
database/sql library.

I also changed the DB.Do() and DB.With() call to DB.Update() and
DB.View(), respectively. This is more intuitive and more inline with
other database verbiage.
2014-03-24 11:43:06 -06:00
Ben Johnson 0866abf733 Merge pull request #87 from benbjohnson/errors
Error refactoring
2014-03-24 08:32:38 -06:00
Ben Johnson 59fde2f664 Error refactoring.
Fixed up a few error issues and refactored out the Error type.
2014-03-24 08:31:15 -06:00
Ben Johnson 7ea635c8fc Merge pull request #86 from benbjohnson/mock
Re-add tests for write failures
2014-03-24 07:49:09 -06:00
Tommi Virtanen e9b2cab0fa Re-add tests for write failures
Commit d2173f5f0e removed the complete
os & syscall mocking layer as overly complex. This commit adds back
the simplest possible thing: hooks to control the database file
writes.

Missing tests: TestDBOpenMetaFileError, TestDBMmapStatError.
These are harder to test without more extensive mocking.

Conflicts:
	db_test.go
2014-03-24 07:47:33 -06:00
Ben Johnson 3c1ecb925e Resolve remaining errcheck warnings. 2014-03-24 07:38:27 -06:00
Tommi Virtanen e0a6f5b2af Check errors from file close in DB.CopyFile
Write errors are often delayed and reported only by the close.

The extra close in defer on success is harmless, (*os.File).Close
protects itself against multiple closes, and this way it's immediately
obvious there is no code path that would leak open files.
2014-03-23 13:27:37 -07:00
Tommi Virtanen cb896f6525 Check spill error in Commit 2014-03-23 13:27:37 -07:00
Tommi Virtanen bfb02aec20 Check meta page write error in Commit 2014-03-23 13:27:36 -07:00
Ben Johnson 42bc0f210a Merge pull request #81 from benbjohnson/tx-closed
Add ErrTxClosed error.
2014-03-23 12:24:32 -06:00
Ben Johnson 482f00fdfc Add ErrTxClosed error.
Commit/Rollback and mutable calls on Tx and Bucket now return ErrTxClosed
if the transaction has already been committed or rolled back. Non-mutable
calls have added an assertion to check if the transaction is closed which
will cause a panic. I don't want to introduce an error return for accessor
methods that are being used improperly so I think the panic is appropriate.
2014-03-23 12:20:16 -06:00
Ben Johnson 8303617b72 Merge pull request #78 from benbjohnson/tx-managed
Mark Do()/With() transaction as managed.
2014-03-23 11:52:10 -06:00
Ben Johnson 76f6ead6b0 Mark Do()/With() transaction as managed.
Transaction created from Do() and With() are now considered "managed".
Managed transactions cannot be manually committed or rolled back since
the Do() and With() functions provide that functionally automatically.
Previously, a Tx could be manually committed and then any changes after
that would be lost.
2014-03-23 10:34:53 -06:00
Ben Johnson 1282a4aff7 Merge pull request #76 from benbjohnson/fsync
fdatasync
2014-03-23 10:01:58 -06:00
Ben Johnson a10ce47f54 Consolidate syscall files. 2014-03-23 08:59:45 -07:00
Ben Johnson fd8a13e837 Merge branch 'fdatasync' of https://github.com/tv42/bolt into fsync 2014-03-23 09:42:21 -06:00
Ben Johnson f0e582d910 Merge pull request #75 from Slacken/32bit_build_fails_bucket_go_67
Fix 32bit build
2014-03-23 09:37:27 -06:00
binz 540d94614d fix 32bit build fails: bucket.go#67 2014-03-23 13:54:51 +08:00
Tommi Virtanen 5ce378b046 Call fdatasync/fsync after writing out non-meta pages
This avoids a case where writes can be reordered so meta page is
written before a page it refers to, potentially causing a corrupt
database after a power loss or kernel crash.
2014-03-22 20:47:08 -07:00
Ben Johnson 6d6303a0a2 Merge pull request #74 from benbjohnson/cli
CLI
2014-03-22 14:12:00 -06:00
Ben Johnson 4f4e15e6dd Fix print. 2014-03-21 23:07:46 -06:00
Ben Johnson 845a4d47ce Add 'bolt buckets'. 2014-03-21 22:56:17 -06:00
Ben Johnson 64a52452d3 Add 'bolt set'. 2014-03-21 22:51:22 -06:00
Ben Johnson 0e4d77d424 Add 'bolt pages'. 2014-03-21 22:34:54 -06:00
Ben Johnson 8fa6531b1c Add 'bolt keys'. 2014-03-21 22:05:28 -06:00
Ben Johnson e8d3ae6287 Add 'bolt get'. 2014-03-21 22:00:34 -06:00
Ben Johnson e86296ede7 Merge pull request #71 from benbjohnson/munmap-fix
Fix db.munmap() to return an error.
2014-03-21 13:32:40 -06:00
Ben Johnson d2173f5f0e Fix db.munmap() to return an error.
Changes munmap to return an error and the DB now implements io.Closer.
I also removed all the OS and Syscall mocking because it's causing issues.
Corrupt file tests need to be recreated but directly using the file system
instead.
2014-03-21 13:21:33 -06:00
Ben Johnson 2eea5766ae Merge pull request #68 from benbjohnson/remove-db-functions
Remove ease-of-use functions from the DB type.
2014-03-21 10:21:47 -06:00
Ben Johnson 3cc959fb1a Remove ease-of-use functions from the DB type.
Functions such as DB.Put(), DB.Get(), and DB.Delete() were originally
added to be easy to use, however, after implementing Bolt in multiple
projects I have found these ease-of-use functions useless. Nearly
every use case requires multiple calls in a single transaction.

Using the DB ease of use functions turned out to be an antipattern.
2014-03-21 09:52:01 -06:00
Ben Johnson 1c7b59a4c2 Merge pull request #65 from benbjohnson/fix-tx-buckets-sort-order
Fix Tx.Buckets() sort order.
2014-03-21 08:45:34 -06:00
Ben Johnson 26afa92faf Fix Bucket.ForEach() comment. 2014-03-15 09:14:20 -06:00
Ben Johnson 60fd6f6604 Merge pull request #66 from tv42/testing-short
Skip long-running tests with go test -short
2014-03-13 17:14:21 -07:00
Tommi Virtanen ed909b43ea Skip long-running tests with go test -short 2014-03-13 17:10:33 -07:00
Ben Johnson 62cf02e21a Fix Tx.Buckets() sort order.
@tv42 reported an issue with bucket names returning incorrectly. Not sure if
this fixes the issue but it is necessary anyway.
2014-03-13 15:08:59 -06:00
Ben Johnson fdd7f2162e Merge pull request #64 from benbjohnson/fix-empty-cursor-last
Fix Cursor.Last() on empty buckets.
2014-03-13 13:51:43 -07:00
Ben Johnson 4132080333 Fix Cursor.Last() on empty buckets.
@tv42 reported that creating a cursor on an empty bucket and then calling
Cursor.Last() causes an index out of range error and panics. This commit
adds a check for the page's item count being greater than zero.

Fixes #63.
2014-03-13 14:39:28 -06:00
Ben Johnson b9b69d867a README 2014-03-10 15:03:26 -07:00
Ben Johnson 4e252b8a7f Merge pull request #61 from benbjohnson/merge-tx
Consolidate Tx and RWTx
2014-03-08 19:45:56 -08:00
Ben Johnson a32d0c5c5f Merge pull request #60 from benbjohnson/tx
Rename Transaction to Tx.
2014-03-08 19:44:10 -08:00
Ben Johnson c551e45a47 Consolidate Tx and RWTx. 2014-03-08 20:40:48 -07:00
Ben Johnson 57376f0905 Rename Transaction to Tx.
I changed the Transaction/RWTransaction types to Tx/RWTx, respectively. This makes the naming
more consistent with other packages such as database/sql. The txnid is changed to txid as well.
2014-03-08 17:04:02 -07:00
Ben Johnson 64fcacedfa Add benchmarks. 2014-03-04 13:23:46 -07:00
Ben Johnson 3a1b152562 Ignore multiple transaction commit/rollback/close. 2014-03-01 12:53:05 -07:00
Ben Johnson 7214e089c0 Merge pull request #57 from benbjohnson/node-aware-cursors
Allow reads of unflushed nodes.
2014-03-01 09:21:11 -07:00
Ben Johnson a1f43f4d60 Allow reads of unflushed nodes.
This commit allows cursors to read updated values from within the
RWTransaction.
2014-03-01 09:13:59 -07:00
Ben Johnson 1eb9e09028 Merge branch 'master' of https://github.com/boltdb/bolt 2014-03-01 07:51:45 -07:00
Ben Johnson 956453b69f Minor refactor. 2014-02-28 15:13:07 -07:00
Ben Johnson 9abba5dfa2 Merge pull request #55 from benbjohnson/fix-mmap-resize
Fix the mmap resize to use the correct size.
2014-02-27 14:37:11 -07:00