]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/recno.3
twalk_r.3: New link to twalk(3) page
[thirdparty/man-pages.git] / man3 / recno.3
CommitLineData
fea681da
MK
1.\" Copyright (c) 1990, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
a9cd9cb7 4.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
fea681da
MK
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\" must display the following acknowledgement:
15.\" This product includes software developed by the University of
16.\" California, Berkeley and its contributors.
17.\" 4. Neither the name of the University nor the names of its contributors
18.\" may be used to endorse or promote products derived from this software
19.\" without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
8c9302dc 32.\" %%%LICENSE_END
fea681da
MK
33.\"
34.\" @(#)recno.3 8.5 (Berkeley) 8/18/94
35.\"
4b8c67d9 36.TH RECNO 3 2017-09-15 "" "Linux Programmer's Manual"
fea681da
MK
37.UC 7
38.SH NAME
39recno \- record number database access method
40.SH SYNOPSIS
41.nf
42.ft B
43#include <sys/types.h>
44#include <db.h>
45.ft R
46.fi
47.SH DESCRIPTION
df21098d
MK
48.IR "Note well" :
49This page documents interfaces provided in glibc up until version 2.1.
50Since version 2.2, glibc no longer provides these interfaces.
51Probably, you are looking for the APIs provided by the
52.I libdb
53library instead.
847e0d88 54.PP
fea681da 55The routine
1c9d4f95 56.BR dbopen (3)
fea681da
MK
57is the library interface to database files.
58One of the supported file formats is record number files.
59The general description of the database access methods is in
31e9a9ec 60.BR dbopen (3),
76c637e1 61this manual page describes only the recno-specific information.
fea681da
MK
62.PP
63The record number data structure is either variable or fixed-length
64records stored in a flat-file format, accessed by the logical record
65number.
66The existence of record number five implies the existence of records
67one through four, and the deletion of record number one causes
68record number five to be renumbered to record number four, as well
69as the cursor, if positioned after record number one, to shift down
70one record.
71.PP
76c637e1 72The recno access-method-specific data structure provided to
1c9d4f95 73.BR dbopen (3)
a9a13a50
MK
74is defined in the
75.I <db.h>
76include file as follows:
fea681da 77.PP
088a639b 78.in +4n
b8302363 79.EX
fea681da 80typedef struct {
c09cb5f4 81 unsigned long flags;
aeb4b1fc
MK
82 unsigned int cachesize;
83 unsigned int psize;
84 int lorder;
85 size_t reclen;
10ff70c5 86 unsigned char bval;
aeb4b1fc 87 char *bfname;
fea681da 88} RECNOINFO;
b8302363 89.EE
ec5a588f 90.in
fea681da
MK
91.PP
92The elements of this structure are defined as follows:
93.TP
fac55da5 94.I flags
cebca1bd 95The flag value is specified by ORing
fea681da
MK
96any of the following values:
97.RS
98.TP
4bd8c614 99.B R_FIXEDLEN
fea681da
MK
100The records are fixed-length, not byte delimited.
101The structure element
102.I reclen
103specifies the length of the record, and the structure element
104.I bval
105is used as the pad character.
106Any records, inserted into the database, that are less than
107.I reclen
108bytes long are automatically padded.
109.TP
4bd8c614 110.B R_NOKEY
fea681da 111In the interface specified by
1c9d4f95 112.BR dbopen (3),
fea681da
MK
113the sequential record retrieval fills in both the caller's key and
114data structures.
4bd8c614
MK
115If the
116.B R_NOKEY
117flag is specified, the
fea681da
MK
118.I cursor
119routines are not required to fill in the key structure.
120This permits applications to retrieve records at the end of files without
121reading all of the intervening records.
122.TP
4bd8c614 123.B R_SNAPSHOT
fea681da 124This flag requires that a snapshot of the file be taken when
1c9d4f95 125.BR dbopen (3)
fea681da
MK
126is called, instead of permitting any unmodified records to be read from
127the original file.
128.RE
129.TP
ec5a588f 130.I cachesize
fea681da
MK
131A suggested maximum size, in bytes, of the memory cache.
132This value is
133.B only
134advisory, and the access method will allocate more memory rather than fail.
135If
136.I cachesize
f89652a6 137is 0 (no size is specified), a default cache is used.
fea681da 138.TP
ec5a588f 139.I psize
fea681da
MK
140The recno access method stores the in-memory copies of its records
141in a btree.
142This value is the size (in bytes) of the pages used for nodes in that tree.
143If
144.I psize
f89652a6 145is 0 (no page size is specified), a page size is chosen based on the
9ee4a2b6 146underlying filesystem I/O block size.
fea681da 147See
31e9a9ec 148.BR btree (3)
fea681da
MK
149for more information.
150.TP
ec5a588f 151.I lorder
fea681da
MK
152The byte order for integers in the stored database metadata.
153The number should represent the order as an integer; for example,
154big endian order would be the number 4,321.
155If
156.I lorder
f89652a6 157is 0 (no order is specified), the current host order is used.
fea681da 158.TP
ec5a588f 159.I reclen
fea681da
MK
160The length of a fixed-length record.
161.TP
ec5a588f 162.I bval
fea681da
MK
163The delimiting byte to be used to mark the end of a record for
164variable-length records, and the pad character for fixed-length
165records.
31a6818e 166If no value is specified, newlines ("\en") are used to mark the end
fea681da
MK
167of variable-length records and fixed-length records are padded with
168spaces.
169.TP
ec5a588f 170.I bfname
fea681da
MK
171The recno access method stores the in-memory copies of its records
172in a btree.
ec5a588f
MK
173If
174.I bfname
175is non-NULL, it specifies the name of the btree file,
1c9d4f95
MK
176as if specified as the filename for a
177.BR dbopen (3)
178of a btree file.
fea681da 179.PP
ec5a588f
MK
180The data part of the key/data pair used by the
181.I recno
182access method
fea681da
MK
183is the same as other access methods.
184The key is different.
185The
186.I data
187field of the key should be a pointer to a memory location of type
188.IR recno_t ,
cd4e22e8 189as defined in the
ec5a588f 190.I <db.h>
a9a13a50 191include file.
fea681da
MK
192This type is normally the largest unsigned integral type available to
193the implementation.
194The
195.I size
196field of the key should be the size of that type.
197.PP
466dbc8b 198Because there can be no metadata associated with the underlying
fea681da 199recno access method files, any changes made to the default values
75b94dc3 200(e.g., fixed record length or byte separator value) must be explicitly
fea681da
MK
201specified each time the file is opened.
202.PP
203In the interface specified by
1c9d4f95 204.BR dbopen (3),
fea681da
MK
205using the
206.I put
207interface to create a new record will cause the creation of multiple,
208empty records if the record number is more than one greater than the
209largest record currently in the database.
210.SH ERRORS
211The
212.I recno
213access method routines may fail and set
214.I errno
215for any of the errors specified for the library routine
31e9a9ec 216.BR dbopen (3)
fea681da
MK
217or the following:
218.TP
747944fe 219.B EINVAL
fea681da
MK
220An attempt was made to add a record to a fixed-length database that
221was too large to fit.
e37e3282
MK
222.SH BUGS
223Only big and little endian byte order is supported.
47297adb 224.SH SEE ALSO
ac5e6a36 225.BR btree (3),
31e9a9ec
MK
226.BR dbopen (3),
227.BR hash (3),
d8aaa1d3 228.BR mpool (3)
847e0d88 229.PP
fea681da
MK
230.IR "Document Processing in a Relational Database System" ,
231Michael Stonebraker, Heidi Stettner, Joseph Kalash, Antonin Guttman,
232Nadene Lynn, Memorandum No. UCB/ERL M82/32, May 1982.