ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/BDB/README
(Generate patch)

Comparing BDB/README (file contents):
Revision 1.6 by root, Tue Dec 25 14:23:21 2007 UTC vs.
Revision 1.9 by root, Sat May 10 20:23:19 2008 UTC

25 db_sync $db; 25 db_sync $db;
26 26
27 # when you also use Coro, management is easy: 27 # when you also use Coro, management is easy:
28 use Coro::BDB; 28 use Coro::BDB;
29 29
30 # automatic result processing with AnyEvent: 30 # automatic event loop intergration with AnyEvent:
31 our $FH; open $FH, "<&=" . BDB::poll_fileno; 31 use AnyEvent::BDB;
32 our $WATCHER = AnyEvent->io (fh => $FH, poll => 'r', cb => \&BDB::poll_cb);
33 32
34 # automatic result processing with EV: 33 # automatic result processing with EV:
35 my $WATCHER = EV::io BDB::poll_fileno, EV::READ, \&BDB::poll_cb; 34 my $WATCHER = EV::io BDB::poll_fileno, EV::READ, \&BDB::poll_cb;
36 35
37 # with Glib: 36 # with Glib:
87 Request has reached the end of its lifetime and holds no resources 86 Request has reached the end of its lifetime and holds no resources
88 anymore (except possibly for the Perl object, but its connection to 87 anymore (except possibly for the Perl object, but its connection to
89 the actual aio request is severed and calling its methods will 88 the actual aio request is severed and calling its methods will
90 either do nothing or result in a runtime error). 89 either do nothing or result in a runtime error).
91 90
91 WIN32 FILENAMES/DATABASE NAME MESS
92 Perl on Win32 supports only ASCII filenames (the reason is that it
93 abuses an internal flag to store wether a filename is Unicode or ANSI,
94 but that flag is used for somethign else in the perl core, so there is
95 no way to detect wether a filename is ANSI or Unicode-encoded). The BDB
96 module tries to work around this issue by assuming that the filename is
97 an ANSI filename and BDB was built for unicode support.
98
92 BERKELEYDB FUNCTIONS 99 BERKELEYDB FUNCTIONS
93 All of these are functions. The create functions simply return a new 100 All of these are functions. The create functions simply return a new
94 object and never block. All the remaining functions all take an optional 101 object and never block. All the remaining functions take an optional
95 callback as last argument. If it is missing, then the function will be 102 callback as last argument. If it is missing, then the function will be
96 executed synchronously. In both cases, $! will reflect the return value 103 executed synchronously. In both cases, $! will reflect the return value
97 of the function. 104 of the function.
98 105
99 BDB functions that cannot block (mostly functions that manipulate 106 BDB functions that cannot block (mostly functions that manipulate
100 settings) are method calls on the relevant objects, so the rule of thumb 107 settings) are method calls on the relevant objects, so the rule of thumb
101 is: if its a method, its not blocking, if its a function, it takes a 108 is: if it's a method, it's not blocking, if it's a function, it takes a
102 callback as last argument. 109 callback as last argument.
103 110
104 In the following, $int signifies an integer return value, "octetstring" 111 In the following, $int signifies an integer return value, "octetstring"
105 is a "binary string" (i.e. a perl string with no character indices 112 is a "binary string" (i.e. a perl string with no character indices
106 >255), "U32" is an unsigned 32 bit integer, "int" is some integer, "NV" 113 >255), "U32" is an unsigned 32 bit integer, "int" is some integer, "NV"
361 flags: SEQ_DEC SEQ_INC SEQ_WRAP 368 flags: SEQ_DEC SEQ_INC SEQ_WRAP
362 $int = $seq->set_range (db_seq_t min, db_seq_t max) 369 $int = $seq->set_range (db_seq_t min, db_seq_t max)
363 370
364 Example: 371 Example:
365 my $seq = $db->sequence; 372 my $seq = $db->sequence;
366 373
367 db_sequence_open $seq, undef, "seq", BDB::CREATE; 374 db_sequence_open $seq, undef, "seq", BDB::CREATE;
368 db_sequence_get $seq, undef, 1, my $value; 375 db_sequence_get $seq, undef, 1, my $value;
369 376
370 SUPPORT FUNCTIONS 377 SUPPORT FUNCTIONS
371 EVENT PROCESSING AND EVENT LOOP INTEGRATION 378 EVENT PROCESSING AND EVENT LOOP INTEGRATION
372 $msg = BDB::strerror [$errno] 379 $msg = BDB::strerror [$errno]
373 Returns the string corresponding to the given errno value. If no 380 Returns the string corresponding to the given errno value. If no
374 argument is given, use $!. 381 argument is given, use $!.
382
383 Note that the BDB module also patches the $! variable directly, so
384 you should be able to get a bdb error string by simply stringifying
385 $!.
375 386
376 $fileno = BDB::poll_fileno 387 $fileno = BDB::poll_fileno
377 Return the *request result pipe file descriptor*. This filehandle 388 Return the *request result pipe file descriptor*. This filehandle
378 must be polled for reading by some mechanism outside this module 389 must be polled for reading by some mechanism outside this module
379 (e.g. Event or select, see below or the SYNOPSIS). If the pipe 390 (e.g. Event or select, see below or the SYNOPSIS). If the pipe
598 with an operating system error or DB_LOCK_NOTGRANTED, the internal 609 with an operating system error or DB_LOCK_NOTGRANTED, the internal
599 TXN_DEADLOCK flag will be set on the transaction. See C<db_txn_finish>, 610 TXN_DEADLOCK flag will be set on the transaction. See C<db_txn_finish>,
600 above. 611 above.
601 612
602SEE ALSO 613SEE ALSO
603 Coro::BDB, IO::AIO. 614 AnyEvent::BDB (event loop integration), Coro::BDB (more natural syntax),
615 IO::AIO (nice to have).
604 616
605AUTHOR 617AUTHOR
606 Marc Lehmann <schmorp@schmorp.de> 618 Marc Lehmann <schmorp@schmorp.de>
607 http://home.schmorp.de/ 619 http://home.schmorp.de/
608 620

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines