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