1.\" Copyright (c) 1990, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 3. Neither the name of the University nor the names of its contributors 13.\" may be used to endorse or promote products derived from this software 14.\" without specific prior written permission. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.\" @(#)recno.3 8.5 (Berkeley) 8/18/94 29.\" 30.Dd August 18, 1994 31.Dt RECNO 3 32.Os 33.Sh NAME 34.Nm recno 35.Nd "record number database access method" 36.Sh SYNOPSIS 37.In sys/types.h 38.In db.h 39.Sh DESCRIPTION 40The routine 41.Fn dbopen 42is the library interface to database files. 43One of the supported file formats is record number files. 44The general description of the database access methods is in 45.Xr dbopen 3 , 46this manual page describes only the 47.Nm 48specific information. 49.Pp 50The record number data structure is either variable or fixed-length 51records stored in a flat-file format, accessed by the logical record 52number. 53The existence of record number five implies the existence of records 54one through four, and the deletion of record number one causes 55record number five to be renumbered to record number four, as well 56as the cursor, if positioned after record number one, to shift down 57one record. 58.Pp 59The 60.Nm 61access method specific data structure provided to 62.Fn dbopen 63is defined in the 64.In db.h 65include file as follows: 66.Bd -literal 67typedef struct { 68 u_long flags; 69 u_int cachesize; 70 u_int psize; 71 int lorder; 72 size_t reclen; 73 u_char bval; 74 char *bfname; 75} RECNOINFO; 76.Ed 77.Pp 78The elements of this structure are defined as follows: 79.Bl -tag -width indent 80.It Va flags 81The flag value is specified by 82.Em or Ns 'ing 83any of the following values: 84.Bl -tag -width indent 85.It Dv R_FIXEDLEN 86The records are fixed-length, not byte delimited. 87The structure element 88.Va reclen 89specifies the length of the record, and the structure element 90.Va bval 91is used as the pad character. 92Any records, inserted into the database, that are less than 93.Va reclen 94bytes long are automatically padded. 95.It Dv R_NOKEY 96In the interface specified by 97.Fn dbopen , 98the sequential record retrieval fills in both the caller's key and 99data structures. 100If the 101.Dv R_NOKEY 102flag is specified, the 103.Em cursor 104routines are not required to fill in the key structure. 105This permits applications to retrieve records at the end of files without 106reading all of the intervening records. 107.It Dv R_SNAPSHOT 108This flag requires that a snapshot of the file be taken when 109.Fn dbopen 110is called, instead of permitting any unmodified records to be read from 111the original file. 112.El 113.It Va cachesize 114A suggested maximum size, in bytes, of the memory cache. 115This value is 116.Em only 117advisory, and the access method will allocate more memory rather than fail. 118If 119.Va cachesize 120is 0 (no size is specified) a default cache is used. 121.It Va psize 122The 123.Nm 124access method stores the in-memory copies of its records 125in a btree. 126This value is the size (in bytes) of the pages used for nodes in that tree. 127If 128.Va psize 129is 0 (no page size is specified) a page size is chosen based on the 130underlying file system I/O block size. 131See 132.Xr btree 3 133for more information. 134.It Va lorder 135The byte order for integers in the stored database metadata. 136The number should represent the order as an integer; for example, 137big endian order would be the number 4,321. 138If 139.Va lorder 140is 0 (no order is specified) the current host order is used. 141.It Va reclen 142The length of a fixed-length record. 143.It Va bval 144The delimiting byte to be used to mark the end of a record for 145variable-length records, and the pad character for fixed-length 146records. 147If no value is specified, newlines 148.Pq Dq \en 149are used to mark the end 150of variable-length records and fixed-length records are padded with 151spaces. 152.It Va bfname 153The 154.Nm 155access method stores the in-memory copies of its records 156in a btree. 157If 158.Va bfname 159is 160.No non\- Ns Dv NULL , 161it specifies the name of the btree file, 162as if specified as the file name for a 163.Fn dbopen 164of a btree file. 165.El 166.Pp 167The data part of the key/data pair used by the 168.Nm 169access method 170is the same as other access methods. 171The key is different. 172The 173.Va data 174field of the key should be a pointer to a memory location of type 175.Ft recno_t , 176as defined in the 177.In db.h 178include file. 179This type is normally the largest unsigned integral type available to 180the implementation. 181The 182.Va size 183field of the key should be the size of that type. 184.Pp 185Because there can be no meta-data associated with the underlying 186.Nm 187access method files, any changes made to the default values 188(e.g.\& fixed record length or byte separator value) must be explicitly 189specified each time the file is opened. 190.Pp 191In the interface specified by 192.Fn dbopen , 193using the 194.Va put 195interface to create a new record will cause the creation of multiple, 196empty records if the record number is more than one greater than the 197largest record currently in the database. 198.Sh ERRORS 199The 200.Nm 201access method routines may fail and set 202.Va errno 203for any of the errors specified for the library routine 204.Xr dbopen 3 205or the following: 206.Bl -tag -width Er 207.It Bq Er EINVAL 208An attempt was made to add a record to a fixed-length database that 209was too large to fit. 210.El 211.Sh SEE ALSO 212.Xr btree 3 , 213.Xr dbopen 3 , 214.Xr hash 3 , 215.Xr mpool 3 216.Rs 217.%T "Document Processing in a Relational Database System" 218.%A Michael Stonebraker 219.%A Heidi Stettner 220.%A Joseph Kalash 221.%A Antonin Guttman 222.%A Nadene Lynn 223.%R "Memorandum No. UCB/ERL M82/32" 224.%D May 1982 225.Re 226.Sh BUGS 227Only big and little endian byte order is supported. 228