OSDN Git Service

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