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.\" $FreeBSD: head/lib/libc/db/man/recno.3 165903 2007-01-09 00:28:16Z imp $ 30.\" 31.Dd August 18, 1994 32.Dt RECNO 3 33.Os 34.Sh NAME 35.Nm recno 36.Nd "record number database access method" 37.Sh LIBRARY 38.Lb libc 39.Sh SYNOPSIS 40.In sys/types.h 41.In db.h 42.Sh DESCRIPTION 43The routine 44.Fn dbopen 45is the library interface to database files. 46One of the supported file formats is record number files. 47The general description of the database access methods is in 48.Xr dbopen 3 , 49this manual page describes only the 50.Nm 51specific information. 52.Pp 53The record number data structure is either variable or fixed-length 54records stored in a flat-file format, accessed by the logical record 55number. 56The existence of record number five implies the existence of records 57one through four, and the deletion of record number one causes 58record number five to be renumbered to record number four, as well 59as the cursor, if positioned after record number one, to shift down 60one record. 61.Pp 62The 63.Nm 64access method specific data structure provided to 65.Fn dbopen 66is defined in the 67.In db.h 68include file as follows: 69.Bd -literal 70typedef struct { 71 unsigned long flags; 72 unsigned int cachesize; 73 unsigned int psize; 74 int lorder; 75 size_t reclen; 76 unsigned char bval; 77 char *bfname; 78} RECNOINFO; 79.Ed 80.Pp 81The elements of this structure are defined as follows: 82.Bl -tag -width indent 83.It Va flags 84The flag value is specified by 85.Em or Ns 'ing 86any of the following values: 87.Bl -tag -width indent 88.It Dv R_FIXEDLEN 89The records are fixed-length, not byte delimited. 90The structure element 91.Va reclen 92specifies the length of the record, and the structure element 93.Va bval 94is used as the pad character. 95Any records, inserted into the database, that are less than 96.Va reclen 97bytes long are automatically padded. 98.It Dv R_NOKEY 99In the interface specified by 100.Fn dbopen , 101the sequential record retrieval fills in both the caller's key and 102data structures. 103If the 104.Dv R_NOKEY 105flag is specified, the 106.Em cursor 107routines are not required to fill in the key structure. 108This permits applications to retrieve records at the end of files without 109reading all of the intervening records. 110.It Dv R_SNAPSHOT 111This flag requires that a snapshot of the file be taken when 112.Fn dbopen 113is called, instead of permitting any unmodified records to be read from 114the original file. 115.El 116.It Va cachesize 117A suggested maximum size, in bytes, of the memory cache. 118This value is 119.Em only 120advisory, and the access method will allocate more memory rather than fail. 121If 122.Va cachesize 123is 0 (no size is specified) a default cache is used. 124.It Va psize 125The 126.Nm 127access method stores the in-memory copies of its records 128in a btree. 129This value is the size (in bytes) of the pages used for nodes in that tree. 130If 131.Va psize 132is 0 (no page size is specified) a page size is chosen based on the 133underlying file system I/O block size. 134See 135.Xr btree 3 136for more information. 137.It Va lorder 138The byte order for integers in the stored database metadata. 139The number should represent the order as an integer; for example, 140big endian order would be the number 4,321. 141If 142.Va lorder 143is 0 (no order is specified) the current host order is used. 144.It Va reclen 145The length of a fixed-length record. 146.It Va bval 147The delimiting byte to be used to mark the end of a record for 148variable-length records, and the pad character for fixed-length 149records. 150If no value is specified, newlines 151.Pq Dq \en 152are used to mark the end 153of variable-length records and fixed-length records are padded with 154spaces. 155.It Va bfname 156The 157.Nm 158access method stores the in-memory copies of its records 159in a btree. 160If 161.Va bfname 162is 163.No non\- Ns Dv NULL , 164it specifies the name of the btree file, 165as if specified as the file name for a 166.Fn dbopen 167of a btree file. 168.El 169.Pp 170The data part of the key/data pair used by the 171.Nm 172access method 173is the same as other access methods. 174The key is different. 175The 176.Va data 177field of the key should be a pointer to a memory location of type 178.Ft recno_t , 179as defined in the 180.In db.h 181include file. 182This type is normally the largest unsigned integral type available to 183the implementation. 184The 185.Va size 186field of the key should be the size of that type. 187.Pp 188Because there can be no meta-data associated with the underlying 189.Nm 190access method files, any changes made to the default values 191(e.g.\& fixed record length or byte separator value) must be explicitly 192specified each time the file is opened. 193.Pp 194In the interface specified by 195.Fn dbopen , 196using the 197.Va put 198interface to create a new record will cause the creation of multiple, 199empty records if the record number is more than one greater than the 200largest record currently in the database. 201.Sh ERRORS 202The 203.Nm 204access method routines may fail and set 205.Va errno 206for any of the errors specified for the library routine 207.Xr dbopen 3 208or the following: 209.Bl -tag -width Er 210.It Bq Er EINVAL 211An attempt was made to add a record to a fixed-length database that 212was too large to fit. 213.El 214.Sh SEE ALSO 215.Xr btree 3 , 216.Xr dbopen 3 , 217.Xr hash 3 , 218.Xr mpool 3 219.Rs 220.%T "Document Processing in a Relational Database System" 221.%A Michael Stonebraker 222.%A Heidi Stettner 223.%A Joseph Kalash 224.%A Antonin Guttman 225.%A Nadene Lynn 226.%R "Memorandum No. UCB/ERL M82/32" 227.%D May 1982 228.Re 229.Sh BUGS 230Only big and little endian byte order is supported. 231