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