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