OSDN Git Service

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