From 5635837565a8ba1f94211d456f5849dc6e300a21 Mon Sep 17 00:00:00 2001 From: pop Date: Wed, 5 Mar 2003 00:28:16 +0000 Subject: [PATCH] Added test for transactions Removed unused files --- perl/IDZebra.i | 2 +- perl/MANIFEST | 6 ------ perl/Makefile.PL.in | 2 +- perl/lib/IDZebra/Session.pm | 13 ++++++++++--- perl/t/01_base.t | 20 ++++++++++++++++++-- perl/zebra_api_ext.c | 20 -------------------- perl/zebra_api_ext.h | 11 ----------- 7 files changed, 30 insertions(+), 44 deletions(-) delete mode 100644 perl/zebra_api_ext.c delete mode 100644 perl/zebra_api_ext.h diff --git a/perl/IDZebra.i b/perl/IDZebra.i index 61a8c61..b434490 100644 --- a/perl/IDZebra.i +++ b/perl/IDZebra.i @@ -235,7 +235,7 @@ int zebra_select_databases (ZebraHandle zh, int num_bases, /* begin transaction (add write lock) (zebraapi.c) */ %name(begin_trans) -void zebra_begin_trans (ZebraHandle zh); +int zebra_begin_trans (ZebraHandle zh, int rw); /* end transaction (remove write lock) (zebraapi.c) */ %name(end_trans) diff --git a/perl/MANIFEST b/perl/MANIFEST index 95990d1..84e5afd 100644 --- a/perl/MANIFEST +++ b/perl/MANIFEST @@ -1,4 +1,3 @@ -.cvsignore IDZebra_wrap.c MANIFEST Makefile.PL @@ -10,9 +9,6 @@ demo/index.sh demo/pod.abs demo/pod.pm demo/zebra.cfg -demo/register -demo/lock -demo/tmp lib/IDZebra.pm lib/IDZebra/Data1.pm lib/IDZebra/Filter.pm @@ -30,7 +26,5 @@ t/05_search.t t/06_retrieval.t t/07_sort.t t/08_scan.t -zebra_api_ext.c -zebra_api_ext.h zebra_perl.c zebra_perl.h diff --git a/perl/Makefile.PL.in b/perl/Makefile.PL.in index 08b600a..c4e13b6 100644 --- a/perl/Makefile.PL.in +++ b/perl/Makefile.PL.in @@ -2,7 +2,7 @@ use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'IDZebra', - 'OBJECT' => 'IDZebra_wrap.o zebra_api_ext.o zebra_perl.o' , + 'OBJECT' => 'IDZebra_wrap.o zebra_perl.o' , 'INC' => "-I../index -I../include @YAZINC@", 'LIBS' => "-L../index -lzebra -L../data1 -ldata1 @ZPERL_LIBS@ @TCL_LIB@ @YAZLIB@", 'OPTIMIZE' => '-g -O2' diff --git a/perl/lib/IDZebra/Session.pm b/perl/lib/IDZebra/Session.pm index 394e8cb..3f402fd 100644 --- a/perl/lib/IDZebra/Session.pm +++ b/perl/lib/IDZebra/Session.pm @@ -1,4 +1,4 @@ -# $Id: Session.pm,v 1.11 2003-03-04 19:33:52 pop Exp $ +# $Id: Session.pm,v 1.12 2003-03-05 00:28:16 pop Exp $ # # Zebra perl API header # ============================================================================= @@ -15,7 +15,7 @@ BEGIN { use IDZebra::Resultset; use IDZebra::ScanList; use IDZebra::RetrievalRecord; - our $VERSION = do { my @r = (q$Revision: 1.11 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + our $VERSION = do { my @r = (q$Revision: 1.12 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # our @ISA = qw(IDZebra::Logger); } @@ -337,7 +337,14 @@ sub errAdd { sub begin_trans { my ($self) = @_; $self->checkzh; - IDZebra::begin_trans($self->{zh}); + if (my $err = IDZebra::begin_trans($self->{zh},1)) { + if ($self->errCode == 2) { + croak ("TRANS_RW not allowed within TRANS_RO"); + } else { + croak("Error starting transaction; code:". + $self->errCode . " message: " . $self->errString); + } + } } sub end_trans { diff --git a/perl/t/01_base.t b/perl/t/01_base.t index 85b2191..0bf814b 100644 --- a/perl/t/01_base.t +++ b/perl/t/01_base.t @@ -1,6 +1,6 @@ #!perl -Tw # ============================================================================= -# $Id: 01_base.t,v 1.2 2003-03-04 19:33:53 pop Exp $ +# $Id: 01_base.t,v 1.3 2003-03-05 00:28:16 pop Exp $ # # Perl API header # ============================================================================= @@ -14,7 +14,7 @@ BEGIN { use strict; use warnings; -use Test::More tests=>9; +use Test::More tests=>10; # ---------------------------------------------------------------------------- # Session opening and closing @@ -25,6 +25,11 @@ BEGIN { } use pod; +# ---------------------------------------------------------------------------- +# Just to be sure... +mkdir ("demo/tmp"); +mkdir ("demo/lock"); +mkdir ("demo/register"); # ---------------------------------------------------------------------------- # Session opening and closing @@ -50,8 +55,19 @@ $sess->group(groupName => 'demo2'); ok(($sess->group->{databaseName} eq "demo2"),"Record group is selected"); +# --------------------------------------------------------------------------- +# Transactions +$sess->begin_read; +eval {$sess->begin_trans;}; +ok (($@ ne ""), $@); +$sess->end_read; + + + + # ---------------------------------------------------------------------------- # Close session + $sess->close; diff --git a/perl/zebra_api_ext.c b/perl/zebra_api_ext.c deleted file mode 100644 index c0927fa..0000000 --- a/perl/zebra_api_ext.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#ifdef WIN32 -#include -#include -#include -#else -#include -#endif - -#include -#include "index.h" -#include -#include -#include "zebra_perl.h" -#include "zebra_api_ext.h" -#include "yaz/log.h" -#include - - diff --git a/perl/zebra_api_ext.h b/perl/zebra_api_ext.h deleted file mode 100644 index fbba0f8..0000000 --- a/perl/zebra_api_ext.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef ZEBRA_API_EXT_H -#define ZEBRA_API_EXT_H - -#include "zebraapi.h" - -void api_records_retrieve (ZebraHandle zh, ODR stream, - const char *setname, Z_RecordComposition *comp, - oid_value input_format, int num_recs, - ZebraRetrievalRecord *recs); - -#endif -- 1.7.10.4