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