]> git.saurik.com Git - apple/libc.git/blame - db/man/FreeBSD/recno.3
Libc-391.5.22.tar.gz
[apple/libc.git] / db / man / FreeBSD / recno.3
CommitLineData
5b2abdfb
A
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
3d9156a7 33.\" $FreeBSD: src/lib/libc/db/man/recno.3,v 1.8 2004/07/02 23:52:10 ru Exp $
5b2abdfb
A
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
45The routine
46.Fn dbopen
47is the library interface to database files.
48One of the supported file formats is record number files.
49The general description of the database access methods is in
50.Xr dbopen 3 ,
51this manual page describes only the
52.Nm
53specific information.
54.Pp
55The record number data structure is either variable or fixed-length
56records stored in a flat-file format, accessed by the logical record
57number.
58The existence of record number five implies the existence of records
59one through four, and the deletion of record number one causes
60record number five to be renumbered to record number four, as well
61as the cursor, if positioned after record number one, to shift down
62one record.
63.Pp
64The
65.Nm
66access method specific data structure provided to
67.Fn dbopen
68is defined in the
3d9156a7 69.In db.h
5b2abdfb
A
70include file as follows:
71.Bd -literal
72typedef 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
83The elements of this structure are defined as follows:
84.Bl -tag -width indent
85.It Va flags
86The flag value is specified by
87.Em or Ns 'ing
88any of the following values:
89.Bl -tag -width indent
90.It Dv R_FIXEDLEN
91The records are fixed-length, not byte delimited.
92The structure element
93.Va reclen
94specifies the length of the record, and the structure element
95.Va bval
96is used as the pad character.
97Any records, inserted into the database, that are less than
98.Va reclen
99bytes long are automatically padded.
100.It Dv R_NOKEY
101In the interface specified by
102.Fn dbopen ,
103the sequential record retrieval fills in both the caller's key and
104data structures.
105If the
106.Dv R_NOKEY
107flag is specified, the
108.Em cursor
109routines are not required to fill in the key structure.
110This permits applications to retrieve records at the end of files without
111reading all of the intervening records.
112.It Dv R_SNAPSHOT
113This flag requires that a snapshot of the file be taken when
114.Fn dbopen
115is called, instead of permitting any unmodified records to be read from
116the original file.
117.El
118.It Va cachesize
119A suggested maximum size, in bytes, of the memory cache.
120This value is
121.Em only
122advisory, and the access method will allocate more memory rather than fail.
123If
124.Va cachesize
125is 0 (no size is specified) a default cache is used.
126.It Va psize
127The
128.Nm
129access method stores the in-memory copies of its records
130in a btree.
131This value is the size (in bytes) of the pages used for nodes in that tree.
132If
133.Va psize
134is 0 (no page size is specified) a page size is chosen based on the
135underlying file system I/O block size.
136See
137.Xr btree 3
138for more information.
139.It Va lorder
140The byte order for integers in the stored database metadata.
141The number should represent the order as an integer; for example,
142big endian order would be the number 4,321.
143If
144.Va lorder
145is 0 (no order is specified) the current host order is used.
146.It Va reclen
147The length of a fixed-length record.
148.It Va bval
149The delimiting byte to be used to mark the end of a record for
150variable-length records, and the pad character for fixed-length
151records.
152If no value is specified, newlines
153.Pq Dq \en
154are used to mark the end
155of variable-length records and fixed-length records are padded with
156spaces.
157.It Va bfname
158The
159.Nm
160access method stores the in-memory copies of its records
161in a btree.
162If
163.Va bfname
164is
165.No non\- Ns Dv NULL ,
166it specifies the name of the btree file,
167as if specified as the file name for a
168.Fn dbopen
169of a btree file.
170.El
171.Pp
172The data part of the key/data pair used by the
173.Nm
174access method
175is the same as other access methods.
176The key is different.
177The
178.Va data
179field of the key should be a pointer to a memory location of type
180.Ft recno_t ,
181as defined in the
3d9156a7 182.In db.h
5b2abdfb
A
183include file.
184This type is normally the largest unsigned integral type available to
185the implementation.
186The
187.Va size
188field of the key should be the size of that type.
189.Pp
190Because there can be no meta-data associated with the underlying
191.Nm
192access method files, any changes made to the default values
3d9156a7 193(e.g.\& fixed record length or byte separator value) must be explicitly
5b2abdfb
A
194specified each time the file is opened.
195.Pp
196In the interface specified by
197.Fn dbopen ,
198using the
199.Va put
200interface to create a new record will cause the creation of multiple,
201empty records if the record number is more than one greater than the
202largest record currently in the database.
203.Sh ERRORS
204The
205.Nm
206access method routines may fail and set
207.Va errno
208for any of the errors specified for the library routine
209.Xr dbopen 3
210or the following:
211.Bl -tag -width Er
212.It Bq Er EINVAL
213An attempt was made to add a record to a fixed-length database that
214was 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
232Only big and little endian byte order is supported.