Message 104

Weird Scan Behavior

X-Added: With Flames (bblib $Revision: 1.4 $)
Return-path: <nburns@andrew.cmu.edu>
X-Andrew-Authenticated-as: 0;andrew.cmu.edu;Network-Mail
Received: from po0.andrew.cmu.edu via trymail for bb+academic.cs.15-721@andrew.cmu.edu
          ID </afs/andrew.cmu.edu/usr0/bb/Mailbox/svpButK00UdYAmBk48>;
          Mon, 22 Oct 2001 23:06:33 -0400 (EDT)
Received: from mx1.andrew.cmu.edu (MX1.ANDREW.CMU.EDU [128.2.10.111])
        by po0.andrew.cmu.edu (8.9.3/8.9.3) with ESMTP id XAA12851
        for <bb+academic.cs.15-721@ams.andrew.cmu.edu>; Mon, 22 Oct 2001 23:06:32 -0400 (EDT)
Received: from surreal (pool-141-158-70-172.pitt.east.verizon.net [141.158.70.172])
        by mx1.andrew.cmu.edu (8.12.0.Beta16/8.12.0.Beta16) with ESMTP id f9N36WeD014431
        for <bb+academic.cs.15-721@andrew.cmu.edu>; Mon, 22 Oct 2001 23:06:32 -0400
Received: from surreal ([127.0.0.1] ident=nburns)
        by surreal with smtp (Exim 3.32 #1 (Debian))
        id 15vrtZ-0001DI-00; Mon, 22 Oct 2001 23:06:25 -0400
Date: Mon, 22 Oct 2001 23:06:24 -0400 (EDT)
From: Neal Burns <nburns@andrew.cmu.edu>
X-Sender: nburns@surreal
To: Spiros Papadimitriou <spapadim+@cs.cmu.edu>
cc: bb+academic.cs.15-721@andrew.cmu.edu
Subject: Weird Scan Behavior
In-Reply-To: <3BD4B95A.90903@cs.cmu.edu>
Message-ID: <Pine.LNX.3.96L.1011022223335.4331A-100000@surreal>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

Spiros,

I hope I got this right, because it was extremely hard to track down, but
it appears that when you position() a Scan to the last record, *after* you
have just read the last record, getNext() will erroneously return DONE.
Got that? IOW, if LastRID is the RID of the last record,

myscan.position(LastRID);
myscan.getNext(rid, recptr, reclen); // succeeds!
myscan.position(LastRID);
myscan.getNext(rid, recptr, reclen); // fails!

does not work as expected. The reason I am doing this is that when I read
a record from S (in SortMerge) that is larger than the current record in
R, I back up the cursor in S and try again with the next record from R.
Incidentally, this situation comes up at the end of Test1.

The exact code that I used to break it is as follows (Test 1 dataset):

char testbuf[1000];
int testlen;
RID testrid, LastRID = {15, 9};
scan_S->position(LastRID);
if(scan_S->getNext(testrid, testbuf, testlen) == OK)
  cout << "first getNext() succeeded!!" << endl;
else
  cout << "first getNext() failed!!" << endl;
scan_S->position(LastRID);
if(scan_S->getNext(testrid, testbuf, testlen) == OK)
  cout << "second getNext() succeeded!!" << endl;
else
  cout << "second getNext() failed!!" << endl;

and the output is

Running Sort Merge Join tests...
first getNext() succeeded!!
second getNext() failed!!

So please take a look at the code for Scan::getNext(), if only to prove
that I am going crazy.

Thanks,

Neal