📄 isam0001.tst
字号:
############################################################################### PBL - Program Base Library, Copyright 2002 Peter Graf#### This file is part of PBL - The Program Base Library.## PBL is free software.#### This program is free software; you can redistribute it and/or modify## it under the terms of the GNU General Public License as published by## the Free Software Foundation; either version 2 of the License, or## (at your option) any later version.#### This program is distributed in the hope that it will be useful,## but WITHOUT ANY WARRANTY; without even the implied warranty of## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the## GNU General Public License for more details.#### You should have received a copy of the GNU General Public License## along with this program; if not, write to the Free Software## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#### For more information on the Program Base Library or Peter Graf,## please see: http://mission.base.com/.#### ISAM file implementation test case, this test case is set up for ## a regression test of the ISAM library, don't change it unless you ## know what you are doing!#### Usage: #### 1. Build the pbliftst executable. make all## 2. Create the sub directory isamtest. mkdir isamtest## 3. Clear the sub directory isamtest. rm imamtest/*## 4. Run the test frame on this file. pbliftst ISAM0001.TST## 5. Compare ISAM0001.TST and pbliftst.log diff ISAM0001.TST pbliftst.log#### There should be no differences reported, if so your build of the## PBL library is most likely ok!################################################################################# Test case 1 - basic test of functionality#### Open the file isam file isamtest/0001main with three index files## 0001key0, 0001dup1 and 0001key2## open the file for update, create if necessary## the index 0001key0 contains unique keys## the index 0001dup1 can contain duplicate keys, ## ( the test frame allows that because its name contains the string 'dup' )## the index 0001key2 contains unique keys#### open filename keyfile1,dkeyfile2,... update##open isamtest/0001main 0001key0,0001dup1,0001key2 1# pblIsamOpen( isamtest/0001main, 3, 1 )# ok!#### Get the first record according to index 0001key0, should report an error#### get index < NEXT | PREV | FIRST | LAST | THIS >##get 0 FIRST# pblIsamGet( 4, 0 )# rc -1, pbl_errno 1003, errno 0#### Delete 100000 records, should report an error#### ndelete n##ndelete 100000# pblIsamDelete( 100000 records )# i 0, rc -1, pbl_errno 1041, errno 0#### Insert one record with keys "key1", "key", "key20" and data "data1"#### insert ,key1,key2... data##insert ,key1,key,key20 data1# pblIsamInsert( 1, ,key1,key,key20, 15, data1, 6 )# rc 0#### Insert one record with keys "long1", "key", "long1" and 'long' data## Note the key "key" is a duplicate key##insert ,long1,key,long1 1data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891# pblIsamInsert( 1, ,long1,key,long1, 16, 1data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891, 1276 )# rc 0#### Insert one record with keys "long2", "key", "long2" and 'long' data## Note the key "key" is a duplicate key##insert ,long2,key,long2 2data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891# pblIsamInsert( 1, ,long2,key,long2, 16, 2data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891, 1276 )# rc 0#### Insert more records with long data##insert ,long3,key,long3 3data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891# pblIsamInsert( 1, ,long3,key,long3, 16, 3data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891, 1276 )# rc 0insert ,long4,key,long4 4data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891# pblIsamInsert( 1, ,long4,key,long4, 16, 4data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891, 1276 )# rc 0#### Read the datalen of the current record, 'long4' the one just inserted##datalen# pblIsamReadDatalen( currentrecord )# datalen 1276#### Read the data of the current record, 'long4' the one just inserted##readdata# pblIsamReadData( currentrecord )# datalen 1276, data 4data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891#### Read alphabetically last record according to index 0001key0## this sets the current record##get 0 LAST# pblIsamGet( 5, 0 )# keylen 5, key long4#### read the datalen and the data again##datalen# pblIsamReadDatalen( currentrecord )# datalen 1276readdata# pblIsamReadData( currentrecord )# datalen 1276, data 4data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891#### Read alphabetically previous record according to index 0001key0## changes the current record to 'long3'##get 0 PREV# pblIsamGet( 3, 0 )# keylen 5, key long3#### Read datalen and data of current record, 'long3'##datalen# pblIsamReadDatalen( currentrecord )# datalen 1276readdata# pblIsamReadData( currentrecord )# datalen 1276, data 3data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891#### Read alphabetically previous record according to index 0001key0## changes the current record to 'long2'##get 0 PREV# pblIsamGet( 3, 0 )# keylen 5, key long2#### Read datalen and data of current record, 'long2'##datalen# pblIsamReadDatalen( currentrecord )# datalen 1276readdata# pblIsamReadData( currentrecord )# datalen 1276, data 2data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891#### Read alphabetically previous record according to index 0001key0## changes the current record to 'long1'##get 0 PREV# pblIsamGet( 3, 0 )# keylen 5, key long1#### Read datalen and data of current record, 'long2'##datalen# pblIsamReadDatalen( currentrecord )# datalen 1276readdata# pblIsamReadData( currentrecord )# datalen 1276, data 1data1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567891#### Read alphabetically previous record according to index 0001key0## changes the current record to 'key1'##get 0 PREV# pblIsamGet( 3, 0 )# keylen 4, key key1#### Read datalen and data of current record, 'key1'##datalen# pblIsamReadDatalen( currentrecord )# datalen 6readdata# pblIsamReadData( currentrecord )# datalen 6, data data1#### Read alphabetically previous record according to index 0001key0## reports an error, because we are positioned on the first record##get 0 PREV# pblIsamGet( 3, 0 )# rc -1, pbl_errno 1003, errno 0#### Read datalen and data of current record, 'key1'##datalen# pblIsamReadDatalen( currentrecord )# datalen 6readdata# pblIsamReadData( currentrecord )# datalen 6, data data1#### Insert a record with an empty value for index 0001key2,## results in an error, because the index needs unique keys## and does therefore not allow empty values##insert ,key8,key, data1# pblIsamInsert( 1, ,key8,key,, 10, data1, 6 )# rc -1, pbl_errno 1006, errno 0#### Insert a record with an value "key20" for index 0001key2,## this should result in an error, because the index needs unique keys## and the value "key20" was already inserted with the very first insert##insert ,key2,key,key20 data1# pblIsamInsert( 1, ,key2,key,key20, 15, data1, 6 )# rc -1, pbl_errno 1002, errno 0#### Flush all changes made so far##flush# pblIsamFlush( 1 )# rc 0#### Insert a record with key values "key2", "key", "key1f"##insert ,key2,key,key1f data1# pblIsamInsert( 1, ,key2,key,key1f, 15, data1, 6 )# rc 0#### Flush all changes made so far##flush# pblIsamFlush( 1 )# rc 0#### Read alphabetically first record according to index 0001key0## sets the current record to 'key1'##get 0 FIRST# pblIsamGet( 4, 0 )# keylen 4, key key1#### Delete the current record#### Note: This positions the current record to the record that## was historically inserted after the 'key1' record## i.e. the 'long1' record##ndelete 1# pblIsamDelete( 1 records )# deleted 1 records, rc 0#### Get the current record according to index 0001key0## should be the 'long1' record, the second record ever inserted!##get 0 THIS# pblIsamGet( 1, 0 )# keylen 5, key long1#### Read alphabetically first record according to index 0001key0## this yields the alphabetically smallest key, 'key2'## and sets the current record to that record##get 0 FIRST# pblIsamGet( 4, 0 )# keylen 4, key key2#### Delete the current record, 'key2'##ndelete 1# pblIsamDelete( 1 records )# deleted 1 records, rc 0#### Insert a record with key values "key1", "key", "key20"##insert ,key1,key,key20 data1# pblIsamInsert( 1, ,key1,key,key20, 15, data1, 6 )# rc 0#### Insert a record with key values "key2", "key", "key1f"##insert ,key2,key,key1f data1# pblIsamInsert( 1, ,key2,key,key1f, 15, data1, 6 )# rc 0#### Read alphabetically last record according to index 0001key0## this sets the current record##get 0 LAST# pblIsamGet( 5, 0 )# keylen 5, key long4#### Read alphabetically first record according to index 0001key0## this sets the current record##get 0 FIRST# pblIsamGet( 4, 0 )# keylen 4, key key1#### Update the index 0001key0 of the record to 'key2' instead of 'key1'## Reports an error because the value 'key2' exists already##updatekey 0 key2# pblIsamUpdateKey( 0, key2, 4 )# rc -1, pbl_errno 1002, errno 0#### Update the index 0001key0 of the record to key to 'key1'##updatekey 0 key1# pblIsamUpdateKey( 0, key1, 4 )# rc 0#### Read alphabetically last record according to index 0001key0## this sets the current record##get 0 LAST# pblIsamGet( 5, 0 )# keylen 5, key long4#### Read alphabetically first record according to index 0001key0## this sets the current record##get 0 FIRST# pblIsamGet( 4, 0 )# keylen 4, key key1#### Update the data of the current record##updatedata da# pblIsamUpdateData( da, 3 )# datalen 3
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -