]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/recno.3
time.1, atexit.3, bsearch.3, dlopen.3, envz_add.3, errno.3, fmtmsg.3, getgrent_r...
[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.\"
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.\"
df21098d 34.TH RECNO 3 2012-04-23 "" "Linux Programmer's Manual"
fea681da
MK
35.UC 7
36.SH NAME
37recno \- record number database access method
38.SH SYNOPSIS
39.nf
40.ft B
41#include <sys/types.h>
42#include <db.h>
43.ft R
44.fi
45.SH DESCRIPTION
df21098d
MK
46.IR "Note well" :
47This page documents interfaces provided in glibc up until version 2.1.
48Since version 2.2, glibc no longer provides these interfaces.
49Probably, you are looking for the APIs provided by the
50.I libdb
51library instead.
52
fea681da 53The routine
1c9d4f95 54.BR dbopen (3)
fea681da
MK
55is the library interface to database files.
56One of the supported file formats is record number files.
57The general description of the database access methods is in
31e9a9ec 58.BR dbopen (3),
fea681da
MK
59this manual page describes only the recno specific information.
60.PP
61The record number data structure is either variable or fixed-length
62records stored in a flat-file format, accessed by the logical record
63number.
64The existence of record number five implies the existence of records
65one through four, and the deletion of record number one causes
66record number five to be renumbered to record number four, as well
67as the cursor, if positioned after record number one, to shift down
68one record.
69.PP
70The recno access method specific data structure provided to
1c9d4f95 71.BR dbopen (3)
a9a13a50
MK
72is defined in the
73.I <db.h>
74include file as follows:
fea681da 75.PP
088a639b 76.in +4n
b9f02710 77.nf
fea681da 78typedef struct {
c09cb5f4 79 unsigned long flags;
aeb4b1fc
MK
80 unsigned int cachesize;
81 unsigned int psize;
82 int lorder;
83 size_t reclen;
10ff70c5 84 unsigned char bval;
aeb4b1fc 85 char *bfname;
fea681da 86} RECNOINFO;
b9f02710 87.fi
ec5a588f 88.in
fea681da
MK
89.PP
90The elements of this structure are defined as follows:
91.TP
92flags
cebca1bd 93The flag value is specified by ORing
fea681da
MK
94any of the following values:
95.RS
96.TP
4bd8c614 97.B R_FIXEDLEN
fea681da
MK
98The records are fixed-length, not byte delimited.
99The structure element
100.I reclen
101specifies the length of the record, and the structure element
102.I bval
103is used as the pad character.
104Any records, inserted into the database, that are less than
105.I reclen
106bytes long are automatically padded.
107.TP
4bd8c614 108.B R_NOKEY
fea681da 109In the interface specified by
1c9d4f95 110.BR dbopen (3),
fea681da
MK
111the sequential record retrieval fills in both the caller's key and
112data structures.
4bd8c614
MK
113If the
114.B R_NOKEY
115flag is specified, the
fea681da
MK
116.I cursor
117routines are not required to fill in the key structure.
118This permits applications to retrieve records at the end of files without
119reading all of the intervening records.
120.TP
4bd8c614 121.B R_SNAPSHOT
fea681da 122This flag requires that a snapshot of the file be taken when
1c9d4f95 123.BR dbopen (3)
fea681da
MK
124is called, instead of permitting any unmodified records to be read from
125the original file.
126.RE
127.TP
ec5a588f 128.I cachesize
fea681da
MK
129A suggested maximum size, in bytes, of the memory cache.
130This value is
131.B only
132advisory, and the access method will allocate more memory rather than fail.
133If
134.I cachesize
135is 0 (no size is specified) a default cache is used.
136.TP
ec5a588f 137.I psize
fea681da
MK
138The recno access method stores the in-memory copies of its records
139in a btree.
140This value is the size (in bytes) of the pages used for nodes in that tree.
141If
142.I psize
143is 0 (no page size is specified) a page size is chosen based on the
144underlying file system I/O block size.
145See
31e9a9ec 146.BR btree (3)
fea681da
MK
147for more information.
148.TP
ec5a588f 149.I lorder
fea681da
MK
150The byte order for integers in the stored database metadata.
151The number should represent the order as an integer; for example,
152big endian order would be the number 4,321.
153If
154.I lorder
155is 0 (no order is specified) the current host order is used.
156.TP
ec5a588f 157.I reclen
fea681da
MK
158The length of a fixed-length record.
159.TP
ec5a588f 160.I bval
fea681da
MK
161The delimiting byte to be used to mark the end of a record for
162variable-length records, and the pad character for fixed-length
163records.
9f8e673e 164If no value is specified, newlines ("\\n") are used to mark the end
fea681da
MK
165of variable-length records and fixed-length records are padded with
166spaces.
167.TP
ec5a588f 168.I bfname
fea681da
MK
169The recno access method stores the in-memory copies of its records
170in a btree.
ec5a588f
MK
171If
172.I bfname
173is non-NULL, it specifies the name of the btree file,
1c9d4f95
MK
174as if specified as the filename for a
175.BR dbopen (3)
176of a btree file.
fea681da 177.PP
ec5a588f
MK
178The data part of the key/data pair used by the
179.I recno
180access method
fea681da
MK
181is the same as other access methods.
182The key is different.
183The
184.I data
185field of the key should be a pointer to a memory location of type
186.IR recno_t ,
a9a13a50 187as defined in th
ec5a588f 188.I <db.h>
a9a13a50 189include file.
fea681da
MK
190This type is normally the largest unsigned integral type available to
191the implementation.
192The
193.I size
194field of the key should be the size of that type.
195.PP
466dbc8b 196Because there can be no metadata associated with the underlying
fea681da 197recno access method files, any changes made to the default values
75b94dc3 198(e.g., fixed record length or byte separator value) must be explicitly
fea681da
MK
199specified each time the file is opened.
200.PP
201In the interface specified by
1c9d4f95 202.BR dbopen (3),
fea681da
MK
203using the
204.I put
205interface to create a new record will cause the creation of multiple,
206empty records if the record number is more than one greater than the
207largest record currently in the database.
208.SH ERRORS
209The
210.I recno
211access method routines may fail and set
212.I errno
213for any of the errors specified for the library routine
31e9a9ec 214.BR dbopen (3)
fea681da
MK
215or the following:
216.TP
747944fe 217.B EINVAL
fea681da
MK
218An attempt was made to add a record to a fixed-length database that
219was too large to fit.
e37e3282
MK
220.SH BUGS
221Only big and little endian byte order is supported.
fea681da 222.SH "SEE ALSO"
ac5e6a36 223.BR btree (3),
31e9a9ec
MK
224.BR dbopen (3),
225.BR hash (3),
d8aaa1d3 226.BR mpool (3)
173fe7e7 227
fea681da
MK
228.IR "Document Processing in a Relational Database System" ,
229Michael Stonebraker, Heidi Stettner, Joseph Kalash, Antonin Guttman,
230Nadene Lynn, Memorandum No. UCB/ERL M82/32, May 1982.