Commit Graph

193 Commits

Author SHA1 Message Date
Howard Chu
fc137e39a3 Add mdb_dbi_flags()
Retrieve the flags from a DB handle.
2013-07-15 10:57:13 -07:00
Howard Chu
501eac2fc4 Fix child txn dirty_room counts in spill/unspill
Don't count pages twice if they're already accounted in an ancestor txn.
2013-07-14 16:53:04 -07:00
Howard Chu
2c3488aeeb More for stale sub-cursor flags
Same fix for cursor_first/last.
2013-07-14 08:28:26 -07:00
Howard Chu
56a41d87d4 Fix stale sub-cursor C_INIT flag
Whenever we enter cursor_set() the sub-cursor's flag must be
cleared. If the new cursor position has valid subdata it will
be initialized again, if not then the sub-cursor has nothing
to point to.
2013-07-14 08:20:18 -07:00
Howard Chu
8ae56c34d5 Tweak comments, defaults should be OK already 2013-07-12 13:55:18 -07:00
Howard Chu
fa7228962b Bump version to 0.9.7 2013-07-12 13:36:05 -07:00
Hallvard Furuseth
f04dc0ebd2 Also set/clear P_KEEP in parent txn's cursors 2013-07-12 13:17:04 -07:00
Howard Chu
e9ed4d75f7 Spill pages, take 3 2013-07-12 13:17:04 -07:00
Howard Chu
d7bc4baf63 Delay touching pages until cursor is positioned.
This avoids unnecessary rewrites of pages that do not change.
(Restructuring for upcoming mdb_page_spill work.)
2013-07-12 13:17:04 -07:00
Hallvard Furuseth
c09db5757d Simplify: Always set C_UNTRACK for tracked cursors.
TODO: Rename C_UNTRACK to C_TRACKED.  Omitted now for readability.
The current name is because it's lazy: not always set when tracked.
2013-07-12 13:17:04 -07:00
Hallvard Furuseth
6741f9c0ef Save freelist using proper mdb_cursor_put().
(Restructuring for upcoming mdb_page_spill work.)
mdb_freelist_save() can't just Get() the destination, since
mdb_page_spill() may have put the destination in the read-only map.

TODO: Can this new put() modify the freelist, which would break it? The
final iteration's put() can shorten the node, the rest uses MDB_CURRENT.

We could set P_KEEP on dirty freeDB leaves and ovpages, since they are
all about to be modified.  But the code in this commit must stay anyway,
if mdb should support dropping a 256G DB. I.e. too big for dirty_list.
2013-07-12 13:17:04 -07:00
Howard Chu
08373439a6 Move code out to mdb_page_dirty() 2013-07-12 13:17:04 -07:00
Howard Chu
87a7f06feb Factor out parent 2013-07-12 13:17:04 -07:00
Howard Chu
ba6dfe0bbb Fix env_read_header() on Windows
Commit d6d2638acc broke read
on zero-length files.
2013-07-12 12:55:08 -07:00
Hallvard Furuseth
3d46d5502a Do not follow uninited cursors' page pointers.
Nor uninited cursors' subcursors' page pointers.
2013-07-10 22:11:44 +02:00
Howard Chu
b711c07f34 Fix rebalance/cursor adjust
When collapsing root, must also move cursor index down,
not just the page pointer.

Also in mtest, break from NEXT loops on error, otherwise it just
prints the previous key/data again, which looks confusing.
2013-07-10 11:04:37 -07:00
Howard Chu
f81eb631ff Cursors: Clear C_EOF when clearing C_INITIALIZED 2013-07-10 08:49:29 -07:00
Howard Chu
64676da8d9 Fixup other cursors after delete op 2013-07-09 14:21:35 -07:00
Hallvard Furuseth
a77767013a ITS#7515 Reject conflicting page versions.
If mdb_page_touch() sees a page in txn's dirty_list, that
is the page version txn's cursors should have.  Fail if
the user may be seeing and depending on another version.
2013-07-07 17:14:38 +02:00
Hallvard Furuseth
be47ca7667 ITS#7515 Fix tracking of parent txn's cursors.
Restore mc_flags and xcursors, they were tracked but not merged.
Simplify: Track parent txn's original cursors after backing them
up, instead of tracking copies and merging them back at commit.
2013-07-07 17:13:27 +02:00
Hallvard Furuseth
9be6af0dcb Simplify MDB_cursor: Drop flags C_ALLOCD,C_SHADOW. 2013-07-07 17:13:27 +02:00
Hallvard Furuseth
3d1e709504 Silence more uninit warnings 2013-07-06 21:42:45 +02:00
Howard Chu
06a3ad08cd Silence uninit warning in prev commit 2013-07-02 02:23:49 -07:00
Howard Chu
589370d880 Tweaks for MDB_MULTIPLE
Terminate loop on intermediate failures, return count of written items,
document usage.
2013-07-02 02:19:17 -07:00
Howard Chu
fb674c1cf5 ITS#7635 simplify 9474c1a0b6 2013-07-01 14:53:29 -07:00
Howard Chu
9474c1a0b6 ITS#7635 fix read txn potential data race 2013-07-01 13:41:23 -07:00
Howard Chu
3347a02905 Fix uninit warnings, lseek usage 2013-06-30 07:40:02 -07:00
Hallvard Furuseth
7f67383552 Fix alloc/free issues.
Page leak, mdb_page_alloc(). On error, don't shorten me_pghead.
Memleak, mdb_ovpage_free(). Free page or keep it in dirty_list.
Bad MIDL, mdb_midl_need(). Fix midl[-1] (allocated size).
2013-06-26 18:02:52 +02:00
Hallvard Furuseth
12c558fe13 Factor out some vars, simplify. 2013-06-26 18:02:48 +02:00
Hallvard Furuseth
b7ce06f5c5 Makefile/user-macro comments. 2013-06-26 18:02:26 +02:00
Hallvard Furuseth
26a25df5fc Tweak I/O, fix last commit. 2013-06-26 18:02:17 +02:00
Hallvard Furuseth
d6d2638acc Improve MDB error handling, drop seek calls.
Catch I/O errors. Do nothing between OS call failure and ErrCode().
Do not use errno after non-OS-errors like write() >= 0, which could
give a failure return of success (errno 0) or some irrelevant error
code.  Drop seek calls, use pwrite/pread/Windows OVERLAPPED offset.
2013-06-22 23:15:10 +02:00
Hallvard Furuseth
a5701cf2fe Fix Windows I/O.
Don't put a 64-bit filesize in a 32-bit int before shifting
down.  Always pass &sizehi to SetFilePointer->maxsize, so
sizelo not is treated a signed distance.  Hide unused vars
when _WIN32.  Reinitialize OVERLAPPED before reuse.
2013-06-22 23:01:30 +02:00
Hallvard Furuseth
3d4ba01e8b Catch more MDB errors. DPRINTF in mdb_env_reset0. 2013-06-22 22:17:41 +02:00
Hallvard Furuseth
51ff20a4d6 Tweak MIDLs, catch errors.
Grow midls earlier in order to catch errors earlier.  Use
mdb_midl_need() instead of mdb_midl_grow(), then mdb_midl_xappend()
needs no error checks. Factor out mdb_midl_append_range().
2013-06-22 22:10:43 +02:00
Hallvard Furuseth
6b200e3beb Factor out MDB variables/expressions, cleanup.
mdb_page_malloc(): Take a txn arg instead of a cursor.
2013-06-22 12:30:04 +02:00
Hallvard Furuseth
9e6ef6c88f Rearrange MDB dirty page code.
Split out mdb_dpage_free(), mdb_page_flush() and clean up.
2013-06-22 11:56:04 +02:00
Hallvard Furuseth
c6f9323b3d Simplify mdb_page_alloc().
Merge if() branches. Restore retry=500 when MDB_PARANOID, for clarity.
2013-06-20 07:41:35 +02:00
Hallvard Furuseth
4a9ee2cb72 ITS#7620: Keep empty IDLs. Tweak mdb_page_alloc().
MDB_env.me_pghead: Don't free it when empty. mdb_ovpage_free()
needs it, but cannot allocate it.
mdb_midl_alloc(): Fill in length=0.
mdb_page_alloc(): Also Skip freeDB if txnid<3, instead of <4,
and consistently DPRINTF consumed IDLs.
2013-06-20 07:41:35 +02:00
Howard Chu
1d94ea5b55 ITS#7623 Clear P_SUBP on conversion from fake page 2013-06-17 22:26:11 +02:00
Hallvard Furuseth
60086c1bc7 ITS#7515 Nested MDB txns: Inherit txn flags.
Committing a nested txn lost the MDB_TXN_DIRTY flag
in the parent, unless the child had set it too.
2013-06-13 08:58:25 +02:00
Hallvard Furuseth
7030ad16e2 Clean up mdb_page_touch(), mdb_page_copy().
When copying, round up/down to aligned sizes. Skip the unused portion,
this was not done when touching a page dirty in the parent txn.
No other change in behavior.

Simplify mdb_page_touch(), including: Drop test m3==mc, the condition
is caught below. Don't "modify" the parent's pgno into the same pgno,
when a nested txn copies a parent's page into its freelist.
2013-06-13 08:58:24 +02:00
Hallvard Furuseth
79844bd446 ITS#7594 Fix MDB cursor tracking with subDBs.
The tracking code should not change the current cursor.
It did when that was a C_SUB cursor, which should not be
checked against the tracked cursors but their xcursors.

However, do not bother to skip the tracking code for the
current cursor when it would not change that cursor anyway.
2013-06-13 08:58:24 +02:00
Hallvard Furuseth
2bacf6e59e ITS#7594 Invalidate a dropped MDB DB's cursors. 2013-06-13 08:58:24 +02:00
Hallvard Furuseth
62e4c4f9d0 Don't #define _GNU_SOURCE if already defined. 2013-06-13 08:58:24 +02:00
Hallvard Furuseth
c37a11a424 More for ITS#7620 Fix mdb_ovpage_free().
Do not binary-search dirty_list, it is unsorted when MDB_WRITEMAP.
Catch errors. In nested txns, put the page in mt_free_pgs after
all since pages dirty in a parent txn would add complexities.
2013-06-13 08:25:25 +02:00
Howard Chu
2d0b362b6f Partial revert c2cac4588a
MDB_NEXT was fine before, duh.
2013-06-12 08:41:32 -07:00
Hallvard Furuseth
99427aa7de Drop me_pgfree, add mdb_freelist_save().
Split up saving me_pghead, to make me_pgfree unneeded. Also mf_pghead
is now a midl. Needed after e7f6767ea8
("Return fresh overflow pages to current pghead").
Tweak MDB_DEBUG freelist output, make it ascending.
2013-06-12 17:20:42 +02:00
Howard Chu
c2cac4588a Fix CURSOR_NEXT/PREV on emptied DB 2013-06-11 17:13:08 -07:00
Howard Chu
bcb67dd22f Make sure mdb_stat() gets valid data 2013-06-08 14:10:08 -07:00