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