DB_File.xs -- Perl 5 interface to Berkeley DB
written by Paul Marquess <Paul.Marquess@btinternet.com>
- last modified 22nd July 1999
- version 1.68
+ last modified 3rd August 1999
+ version 1.69
All comments/suggestions/problems are welcome
Fixed a small memory leak in the filter code.
1.68 - fixed backward compatability bug with R_IAFTER & R_IBEFORE
merged in the 5.005_58 changes
+ 1.69 - fixed a bug in push -- DB_APPEND wasn't working properly.
+ Fixed the R_SETCURSOR bug introduced in 1.68
+ Added a new Perl variable $DB_File::db_ver
+
#define R_NEXT DB_NEXT
#define R_NOOVERWRITE DB_NOOVERWRITE
#define R_PREV DB_PREV
-#define R_SETCURSOR (-1 )
+#if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 5
+#define R_SETCURSOR 0x800000
+#else
+#define R_SETCURSOR (-100)
+#endif
#define R_RECNOSYNC 0
#define R_FIXEDLEN DB_FIXEDLEN
#define R_DUP DB_DUP
#define db_get(db, key, value, flags) ((db->dbp)->get)(db->dbp, TXN &key, &value, flags)
#ifdef DB_VERSION_MAJOR
-#define db_DESTROY(db) ((db->dbp)->close)(db->dbp, 0)
+#define db_DESTROY(db) ( db->cursor->c_close(db->cursor),\
+ db->dbp->close(db->dbp, 0) )
#define db_close(db) ((db->dbp)->close)(db->dbp, 0)
#define db_del(db, key, flags) (flagSet(flags, R_CURSOR) \
? ((db->cursor)->c_del)(db->cursor, 0) \
static void
GetVersionInfo(pTHX)
{
- SV * ver_sv = perl_get_sv("DB_File::db_version", TRUE) ;
+ SV * version_sv = perl_get_sv("DB_File::db_version", TRUE) ;
+ SV * ver_sv = perl_get_sv("DB_File::db_ver", TRUE) ;
#ifdef DB_VERSION_MAJOR
int Major, Minor, Patch ;
Major, Minor, Patch) ;
#if PERL_VERSION > 3
- sv_setpvf(ver_sv, "%d.%d", Major, Minor) ;
+ sv_setpvf(version_sv, "%d.%d", Major, Minor) ;
+ sv_setpvf(ver_sv, "%d.%03d%03d", Major, Minor, Patch) ;
#else
{
char buffer[40] ;
sprintf(buffer, "%d.%d", Major, Minor) ;
+ sv_setpv(version_sv, buffer) ;
+ sprintf(buffer, "%d.%03d%03d", Major, Minor, Patch) ;
sv_setpv(ver_sv, buffer) ;
}
#endif
#else
+ sv_setiv(version_sv, 1) ;
sv_setiv(ver_sv, 1) ;
#endif
DBT_flags(value) ;
CurrentDB = db ;
#ifdef DB_VERSION_MAJOR
+ RETVAL = do_SEQ(db, key, value, DB_LAST) ;
RETVAL = 0 ;
key = empty ;
for (i = 1 ; i < items ; ++i)
undef $X ;
untie(%h);
-
# tie to the same file again
ok(26, $X = tie(%h,'DB_File',$Dfile, O_RDWR, 0640, $DB_BTREE)) ;
}
+#{
+# # R_SETCURSOR
+# use strict ;
+# my (%h, $db) ;
+# unlink $Dfile;
+#
+# ok(156, $db = tie(%h, 'DB_File', $Dfile, O_RDWR|O_CREAT, 0640, $DB_BTREE ) );
+#
+# $h{abc} = 33 ;
+# my $k = "newest" ;
+# my $v = 44 ;
+# my $status = $db->put($k, $v, R_SETCURSOR) ;
+# print "status = [$status]\n" ;
+# ok(157, $status == 0) ;
+# $status = $db->del($k, R_CURSOR) ;
+# print "status = [$status]\n" ;
+# ok(158, $status == 0) ;
+# $k = "newest" ;
+# ok(159, $db->get($k, $v, R_CURSOR)) ;
+#
+# ok(160, keys %h == 1) ;
+#
+# undef $db ;
+# untie %h;
+# unlink $Dfile;
+#}
+
exit ;