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