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