Hallvard Furuseth
9c49ef1d71
Avoid compiling debug args with C90 compilers.
...
Use double DPRINTF() parenthesis, so varargs macros are not needed.
Parenthesize MDB_DEBUG, in case the user defines it as foo || bar.
11 years ago
Hallvard Furuseth
76d31573a4
Refuse ops on bad txns
11 years ago
Hallvard Furuseth
9beea541e1
Replace EINVALs with generalized MDB_INCOMPATIBLE.
...
Also check xcursor instead of DUPSORT, it's slightly briefer.
11 years ago
Salvador Ortiz
86551828ab
ITS#7660 Add mdb_txn_env to API
11 years ago
Hallvard Furuseth
5645812f41
mdb_txn_commit(): Always commit if MDB_TXN_SPILLS.
...
Checking dirty_list was insufficient after a spill
with no named databases and no positioned cursors.
11 years ago
Salvador Ortiz
92eb220184
ITS#7661 mdb_dbi_flags(): Allow main DBI
11 years ago
Salvador Ortiz
335f0e4cee
mdb_del must ignore data if db not opened with MDB_DUPSORT
11 years ago
Howard Chu
1ac3c8308f
Add mdb_env_get_maxkeysize()
11 years ago
Hallvard Furuseth
1ecd86b14c
Replace unpredictable EINVAL error returns.
...
Return EINVAL only for simple programmer errors.
11 years ago
Hallvard Furuseth
22c104c5d7
Re-fix reader-pid code
11 years ago
Hallvard Furuseth
38b11b1de1
mdb_cursorpages_mark: Mark current txn and no more.
...
Ignore parent txn cursors since it is the current txn's dirty_list
which will be flushed. But check the current txn also when clearing,
since cursors can have pages which are dirty in a parent.
Check !mc_xcursor instead of !MDB_DUPSORT. Equivalent for valid
data, but a bit safer if the sub-DB flags are corrupt.
11 years ago
Hallvard Furuseth
2bd5d8102e
Fix mdb_ovpage_free() vs. spill.
...
Ensure me_pghead has room before removing from spill/dirty list.
Don't return pages to me_pghead in nested txns, use mt_free_pgs.
11 years ago
Hallvard Furuseth
c3547e81f3
Fix page spilling when MDB_WRITEMAP.
...
mdb_page_spill(): Don't binary-search the unsorted dirty_list.
mdb_page_flush(): Don't overwrite unprocessed dirty_list items.
11 years ago
Hallvard Furuseth
ee5ba85565
Set MDB_TXN_ERROR when inconsistent txn state
11 years ago
Hallvard Furuseth
ffd2287b55
Factor out MDB_env.
11 years ago
Hallvard Furuseth
d66739f947
MDB_LOCK_VERSION -> MDB_LOCK_FORMAT.
...
Pid locking needs a different lockfile-version: MDB_env's with and
without pid locking must not coexist, they can sabotage each other.
Store MDB_LOCK_FORMAT = (version | "use locking" flag) instead.
11 years ago
Hallvard Furuseth
1878213092
Fix mdb_reader_pid().
...
Treat unexpected errors as "don't know". Invert Pidcheck return
value, so nonzero including error codes = "the process may exist".
On Windows: Catch exited but still existing processes. Handle
undefined PROCESS_QUERY_LIMITED_INFORMATION.
On Unix: don't trust F_GETLK error to leave the input alone,
the fcntl() doc seems unclear.
11 years ago
Howard Chu
636c2d2a29
Use proper printf format on Windows
11 years ago
Hallvard Furuseth
74ed1757a4
Silence warnings
11 years ago
Hallvard Furuseth
27435aa5ac
Tweak comments
11 years ago
Howard Chu
2cc2574d84
Tweak prev commit again
...
Make sure errors are propagated from init_meta
11 years ago
Howard Chu
bc03467040
Fix typo in Win32 branch
11 years ago
Howard Chu
254b77e63d
Cleanup prev commit
...
Loop on copyfd meta write, since pipes may return after partial write.
11 years ago
Howard Chu
eff35fcb2a
ITS#7652 fix I/O error checks
...
partial revert of d6d2638acc
and
26a25df5fc
The original code was already tested and working correctly.
11 years ago
Howard Chu
acf20f77f3
Tweak mdb_envinfo numreaders
...
Return the actual shared reader count when it exists, not
just the current process env's reader count.
11 years ago
Howard Chu
e8ba9dbd28
ITS#7615 use shorter names for semaphores
...
NetBSD can only handle up to 14 chars, we were using 21. Now
we encode to 15, and for NetBSD truncate the last char.
11 years ago
Howard Chu
de72c08660
Tweak reader_pid check
...
Check again after acquiring rmutex. Avoids potential issue with
a duplicate pid coming in between initial check and rmutex.
12 years ago
Howard Chu
b1dc72b6b5
Get pid lock outside of rmutex
...
Avoid holding rmutex for longer than necessary.
12 years ago
Howard Chu
5ca73f864f
Tweak reader checks
...
Use mti_numreaders for loop limit, not me_maxreaders.
12 years ago
Howard Chu
a4bbe57f8b
Add mdb_reader_check()
12 years ago
Howard Chu
4d7c9e5bca
Split MDB_VERSION to MDB_DATA/MDB_LOCK VERSION
12 years ago
Howard Chu
68a0adc59f
Tweak reader_list
12 years ago
Howard Chu
360d0492db
Tweak mdb_stat(1)
...
Don't obtain reader txn before displaying reader table. Exit
after reader table if no other DB query options were given.
12 years ago
Howard Chu
49289f0d2e
Add mdb_reader_list()
...
Dump the active slots in the reader table.
12 years ago
Howard Chu
fc137e39a3
Add mdb_dbi_flags()
...
Retrieve the flags from a DB handle.
12 years ago
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.
12 years ago
Howard Chu
2c3488aeeb
More for stale sub-cursor flags
...
Same fix for cursor_first/last.
12 years ago
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.
12 years ago
Hallvard Furuseth
f04dc0ebd2
Also set/clear P_KEEP in parent txn's cursors
12 years ago
Howard Chu
e9ed4d75f7
Spill pages, take 3
12 years ago
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.)
12 years ago
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.
12 years ago
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.
12 years ago
Howard Chu
08373439a6
Move code out to mdb_page_dirty()
12 years ago
Howard Chu
87a7f06feb
Factor out parent
12 years ago
Howard Chu
ba6dfe0bbb
Fix env_read_header() on Windows
...
Commit d6d2638acc
broke read
on zero-length files.
12 years ago
Hallvard Furuseth
3d46d5502a
Do not follow uninited cursors' page pointers.
...
Nor uninited cursors' subcursors' page pointers.
12 years ago
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.
12 years ago
Howard Chu
f81eb631ff
Cursors: Clear C_EOF when clearing C_INITIALIZED
12 years ago
Howard Chu
64676da8d9
Fixup other cursors after delete op
12 years ago