]> git.ozlabs.org Git - ccan/blob - ccan/tdb2/doc/TDB1_porting.txt
tdb2: check PID if we are holding a lock.
[ccan] / ccan / tdb2 / doc / TDB1_porting.txt
1 Interface differences between TDB1 and TDB2.
2
3 - tdb2 uses 'struct tdb_data', tdb1 uses 'struct TDB_DATA'.  Use the
4   TDB_DATA typedef if you want portability between the two.
5
6 - tdb2 functions return 0 on success, and a negative error on failure,
7   whereas tdb1 functions returned 0 on success, and -1 on failure.  tdb1
8   then used tdb_error() to determine the error.
9
10 - tdb2's tdb_fetch() returns an error, tdb1's returned the data directly
11   (or tdb_null, and you were supposed to check tdb_error() to find out why).
12
13 - tdb2's tdb_nextkey() frees the old key's dptr, in tdb2 you needed to do
14   this manually.
15
16 - tdb1's tdb_open/tdb_open_ex took an explicit hash size.  tdb2's hash table
17   resizes as required.
18
19 - tdb2 uses a linked list of attribute structures to implement logging and
20   alternate hashes.  tdb1 used tdb_open_ex, which was not extensible.
21
22 - tdb2 does locking on read-only databases (ie. O_RDONLY passed to tdb_open).
23   tdb1 did not: use the TDB_NOLOCK flag if you want to suppress locking.
24
25 - tdb2's log function is simpler than tdb1's log function.  The string is
26   already formatted, and it takes an enum tdb_log_level not a tdb_debug_level,
27   and which has only three values: TDB_LOG_ERROR, TDB_LOG_USE_ERROR and
28   TDB_LOG_WARNING.
29
30 - tdb2 provides tdb_deq() for comparing two struct tdb_data.
31
32 - tdb2's tdb_name() returns a copy of the name even for TDB_INTERNAL dbs.
33
34 - tdb2 does not need tdb_reopen() or tdb_reopen_all().  If you call
35   fork() after during certain operations the child should close the
36   tdb, or complete the operations before continuing to use the tdb:
37
38         tdb_transaction_start(): child must tdb_transaction_cancel()
39         tdb_lockall(): child must call tdb_unlockall()
40         tdb_lockall_read(): child must call tdb_unlockall_read()
41         tdb_chainlock(): child must call tdb_chainunlock()
42         tdb_parse() callback: child must return from tdb_parse()