1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate * CDDL HEADER START
3*0Sstevel@tonic-gate *
4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*0Sstevel@tonic-gate * with the License.
8*0Sstevel@tonic-gate *
9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate * and limitations under the License.
13*0Sstevel@tonic-gate *
14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate *
20*0Sstevel@tonic-gate * CDDL HEADER END
21*0Sstevel@tonic-gate */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate * db_index.cc
24*0Sstevel@tonic-gate *
25*0Sstevel@tonic-gate * Copyright 1988-2002 Sun Microsystems, Inc. All rights reserved.
26*0Sstevel@tonic-gate * Use is subject to license terms.
27*0Sstevel@tonic-gate */
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI"
30*0Sstevel@tonic-gate
31*0Sstevel@tonic-gate #include <stdio.h>
32*0Sstevel@tonic-gate #include <malloc.h>
33*0Sstevel@tonic-gate #include "db_headers.h"
34*0Sstevel@tonic-gate #include "db_index.h"
35*0Sstevel@tonic-gate #include "db_pickle.h"
36*0Sstevel@tonic-gate
37*0Sstevel@tonic-gate #include "nisdb_mt.h"
38*0Sstevel@tonic-gate #include "nisdb_rw.h"
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gate static int hashsizes[] = { /* hashtable sizes */
41*0Sstevel@tonic-gate 11,
42*0Sstevel@tonic-gate 113,
43*0Sstevel@tonic-gate 337,
44*0Sstevel@tonic-gate 977,
45*0Sstevel@tonic-gate 2053,
46*0Sstevel@tonic-gate 4073,
47*0Sstevel@tonic-gate 8011,
48*0Sstevel@tonic-gate 16001,
49*0Sstevel@tonic-gate 0
50*0Sstevel@tonic-gate };
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gate // prevents wrap around numbers from being passed
53*0Sstevel@tonic-gate #define CALLOC_LIMIT 536870911
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gate /* Constructor: creates empty index. */
db_index()56*0Sstevel@tonic-gate db_index::db_index()
57*0Sstevel@tonic-gate {
58*0Sstevel@tonic-gate tab = NULL;
59*0Sstevel@tonic-gate table_size = 0;
60*0Sstevel@tonic-gate count = 0;
61*0Sstevel@tonic-gate case_insens = FALSE;
62*0Sstevel@tonic-gate INITRW(index);
63*0Sstevel@tonic-gate /* grow(); */
64*0Sstevel@tonic-gate }
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate /* Destructor: deletes index, including all associated db_index_entry. */
~db_index()68*0Sstevel@tonic-gate db_index::~db_index()
69*0Sstevel@tonic-gate {
70*0Sstevel@tonic-gate WRITELOCKV(this, "w db_index::~db_index");
71*0Sstevel@tonic-gate reset();
72*0Sstevel@tonic-gate DESTROYRW(index);
73*0Sstevel@tonic-gate }
74*0Sstevel@tonic-gate
75*0Sstevel@tonic-gate /* Get rid of table and all associated entries, and reset counters */
76*0Sstevel@tonic-gate void
reset()77*0Sstevel@tonic-gate db_index::reset()
78*0Sstevel@tonic-gate {
79*0Sstevel@tonic-gate db_index_entry * curr, *n;
80*0Sstevel@tonic-gate int i;
81*0Sstevel@tonic-gate
82*0Sstevel@tonic-gate WRITELOCKV(this, "w db_index::reset");
83*0Sstevel@tonic-gate /* Add sanity test in case table was corrupted */
84*0Sstevel@tonic-gate if (tab != NULL) {
85*0Sstevel@tonic-gate for (i = 0; i < table_size; i++) { // go through table
86*0Sstevel@tonic-gate curr = tab[i];
87*0Sstevel@tonic-gate while (curr != NULL) { // go through bucket
88*0Sstevel@tonic-gate n = curr->getnextentry();
89*0Sstevel@tonic-gate delete curr;
90*0Sstevel@tonic-gate curr = n;
91*0Sstevel@tonic-gate }
92*0Sstevel@tonic-gate }
93*0Sstevel@tonic-gate }
94*0Sstevel@tonic-gate
95*0Sstevel@tonic-gate delete tab; // get rid of table itself
96*0Sstevel@tonic-gate
97*0Sstevel@tonic-gate tab = NULL;
98*0Sstevel@tonic-gate table_size = count = 0;
99*0Sstevel@tonic-gate WRITEUNLOCKV(this, "wu db_index::reset");
100*0Sstevel@tonic-gate }
101*0Sstevel@tonic-gate
102*0Sstevel@tonic-gate
103*0Sstevel@tonic-gate /*
104*0Sstevel@tonic-gate * Initialize index according to the specification of the key descriptor
105*0Sstevel@tonic-gate * Currently, only affects case_insens flag of index.
106*0Sstevel@tonic-gate */
107*0Sstevel@tonic-gate void
init(db_key_desc * k)108*0Sstevel@tonic-gate db_index::init(db_key_desc * k)
109*0Sstevel@tonic-gate {
110*0Sstevel@tonic-gate WRITELOCKV(this, "w db_index::init");
111*0Sstevel@tonic-gate if ((k->key_flags)&DB_KEY_CASE)
112*0Sstevel@tonic-gate case_insens = TRUE;
113*0Sstevel@tonic-gate WRITEUNLOCKV(this, "wu db_index::init");
114*0Sstevel@tonic-gate }
115*0Sstevel@tonic-gate
116*0Sstevel@tonic-gate /* Returns the next size to use for the hash table */
117*0Sstevel@tonic-gate static long unsigned
get_next_hashsize(long unsigned oldsize)118*0Sstevel@tonic-gate get_next_hashsize(long unsigned oldsize)
119*0Sstevel@tonic-gate {
120*0Sstevel@tonic-gate long unsigned newsize = 0, n;
121*0Sstevel@tonic-gate if (oldsize == 0)
122*0Sstevel@tonic-gate newsize = hashsizes[0];
123*0Sstevel@tonic-gate else {
124*0Sstevel@tonic-gate for (n = 0; newsize = hashsizes[n++]; )
125*0Sstevel@tonic-gate if (oldsize == newsize) {
126*0Sstevel@tonic-gate newsize = hashsizes[n]; /* get next size */
127*0Sstevel@tonic-gate break;
128*0Sstevel@tonic-gate }
129*0Sstevel@tonic-gate if (newsize == 0)
130*0Sstevel@tonic-gate newsize = oldsize * 2 + 1; /* just double */
131*0Sstevel@tonic-gate }
132*0Sstevel@tonic-gate return (newsize);
133*0Sstevel@tonic-gate }
134*0Sstevel@tonic-gate
135*0Sstevel@tonic-gate /*
136*0Sstevel@tonic-gate * Grow the current hashtable upto the next size.
137*0Sstevel@tonic-gate * The contents of the existing hashtable is copied to the new one and
138*0Sstevel@tonic-gate * relocated according to its hashvalue relative to the new size.
139*0Sstevel@tonic-gate * Old table is deleted after the relocation.
140*0Sstevel@tonic-gate */
141*0Sstevel@tonic-gate void
grow()142*0Sstevel@tonic-gate db_index::grow()
143*0Sstevel@tonic-gate {
144*0Sstevel@tonic-gate long unsigned oldsize = table_size, i;
145*0Sstevel@tonic-gate db_index_entry_p * oldtab = tab;
146*0Sstevel@tonic-gate
147*0Sstevel@tonic-gate WRITELOCKV(this, "w db_index::grow");
148*0Sstevel@tonic-gate table_size = get_next_hashsize(table_size);
149*0Sstevel@tonic-gate
150*0Sstevel@tonic-gate #ifdef DEBUG
151*0Sstevel@tonic-gate if (debug > 3)
152*0Sstevel@tonic-gate fprintf(ddt, "savehash GROWING to %d\n", table_size);
153*0Sstevel@tonic-gate #endif
154*0Sstevel@tonic-gate
155*0Sstevel@tonic-gate if (table_size > CALLOC_LIMIT) {
156*0Sstevel@tonic-gate table_size = oldsize;
157*0Sstevel@tonic-gate WRITEUNLOCKV(this,
158*0Sstevel@tonic-gate "wu db_index::grow: table size exceeds calloc limit");
159*0Sstevel@tonic-gate FATAL("db_index::grow: table size exceeds calloc limit",
160*0Sstevel@tonic-gate DB_MEMORY_LIMIT);
161*0Sstevel@tonic-gate }
162*0Sstevel@tonic-gate
163*0Sstevel@tonic-gate if ((tab = (db_index_entry_p*)
164*0Sstevel@tonic-gate calloc((unsigned int) table_size,
165*0Sstevel@tonic-gate sizeof (db_index_entry_p))) == NULL) {
166*0Sstevel@tonic-gate tab = oldtab; // restore previous table info
167*0Sstevel@tonic-gate table_size = oldsize;
168*0Sstevel@tonic-gate WRITEUNLOCKV(this,
169*0Sstevel@tonic-gate "wu db_index::grow: cannot allocate space");
170*0Sstevel@tonic-gate FATAL("db_index::grow: cannot allocate space", DB_MEMORY_LIMIT);
171*0Sstevel@tonic-gate }
172*0Sstevel@tonic-gate
173*0Sstevel@tonic-gate if (oldtab != NULL) { // must transfer contents of old to new
174*0Sstevel@tonic-gate for (i = 0; i < oldsize; i++) {
175*0Sstevel@tonic-gate oldtab[i]->relocate(tab, table_size);
176*0Sstevel@tonic-gate }
177*0Sstevel@tonic-gate delete oldtab; // delete old hashtable
178*0Sstevel@tonic-gate }
179*0Sstevel@tonic-gate WRITEUNLOCKV(this, "wu db_index::grow");
180*0Sstevel@tonic-gate }
181*0Sstevel@tonic-gate
182*0Sstevel@tonic-gate /*
183*0Sstevel@tonic-gate * Look up given index value in hashtable.
184*0Sstevel@tonic-gate * Return pointer to db_index_entries that match the given value, linked
185*0Sstevel@tonic-gate * via the 'next_result' pointer. Return in 'how_many_found' the size
186*0Sstevel@tonic-gate * of this list. Return NULL if not found.
187*0Sstevel@tonic-gate */
188*0Sstevel@tonic-gate db_index_entry *
lookup(item * index_value,long * how_many_found,db_table * table,bool_t checkTTL)189*0Sstevel@tonic-gate db_index::lookup(item *index_value, long *how_many_found,
190*0Sstevel@tonic-gate db_table *table, bool_t checkTTL)
191*0Sstevel@tonic-gate {
192*0Sstevel@tonic-gate register unsigned long hval;
193*0Sstevel@tonic-gate unsigned long bucket;
194*0Sstevel@tonic-gate db_index_entry *ret;
195*0Sstevel@tonic-gate
196*0Sstevel@tonic-gate READLOCK(this, NULL, "r db_index::lookup");
197*0Sstevel@tonic-gate if (index_value == NULL || table_size == 0 || tab == NULL) {
198*0Sstevel@tonic-gate READUNLOCK(this, NULL, "ru db_index::lookup");
199*0Sstevel@tonic-gate return (NULL);
200*0Sstevel@tonic-gate }
201*0Sstevel@tonic-gate hval = index_value->get_hashval(case_insens);
202*0Sstevel@tonic-gate bucket = hval % table_size;
203*0Sstevel@tonic-gate
204*0Sstevel@tonic-gate db_index_entry_p fst = tab[bucket ];
205*0Sstevel@tonic-gate
206*0Sstevel@tonic-gate if (fst != NULL)
207*0Sstevel@tonic-gate ret = fst->lookup(case_insens, hval,
208*0Sstevel@tonic-gate index_value, how_many_found);
209*0Sstevel@tonic-gate else
210*0Sstevel@tonic-gate ret = NULL;
211*0Sstevel@tonic-gate
212*0Sstevel@tonic-gate if (ret != NULL && checkTTL && table != NULL) {
213*0Sstevel@tonic-gate if (!table->cacheValid(ret->getlocation()))
214*0Sstevel@tonic-gate ret = NULL;
215*0Sstevel@tonic-gate }
216*0Sstevel@tonic-gate
217*0Sstevel@tonic-gate READUNLOCK(this, ret, "ru db_index::lookup");
218*0Sstevel@tonic-gate return (ret);
219*0Sstevel@tonic-gate }
220*0Sstevel@tonic-gate
221*0Sstevel@tonic-gate /*
222*0Sstevel@tonic-gate * Remove the entry with the given index value and location 'recnum'.
223*0Sstevel@tonic-gate * If successful, return DB_SUCCESS; otherwise DB_NOTUNIQUE if index_value
224*0Sstevel@tonic-gate * is null; DB_NOTFOUND if entry is not found.
225*0Sstevel@tonic-gate * If successful, decrement count of number of entries in hash table.
226*0Sstevel@tonic-gate */
227*0Sstevel@tonic-gate db_status
remove(item * index_value,entryp recnum)228*0Sstevel@tonic-gate db_index::remove(item* index_value, entryp recnum)
229*0Sstevel@tonic-gate {
230*0Sstevel@tonic-gate register unsigned long hval;
231*0Sstevel@tonic-gate unsigned long bucket;
232*0Sstevel@tonic-gate register db_index_entry *fst;
233*0Sstevel@tonic-gate db_status ret;
234*0Sstevel@tonic-gate
235*0Sstevel@tonic-gate if (index_value == NULL)
236*0Sstevel@tonic-gate return (DB_NOTUNIQUE);
237*0Sstevel@tonic-gate WRITELOCK(this, DB_LOCK_ERROR, "w db_index::remove");
238*0Sstevel@tonic-gate if (table_size == 0 || tab == NULL) {
239*0Sstevel@tonic-gate WRITEUNLOCK(this, DB_NOTFOUND, "wu db_index::remove");
240*0Sstevel@tonic-gate return (DB_NOTFOUND);
241*0Sstevel@tonic-gate }
242*0Sstevel@tonic-gate hval = index_value->get_hashval(case_insens);
243*0Sstevel@tonic-gate
244*0Sstevel@tonic-gate bucket = hval % table_size;
245*0Sstevel@tonic-gate
246*0Sstevel@tonic-gate fst = tab[bucket];
247*0Sstevel@tonic-gate if (fst == NULL)
248*0Sstevel@tonic-gate ret = DB_NOTFOUND;
249*0Sstevel@tonic-gate else if (fst->remove(&tab[bucket], case_insens, hval, index_value,
250*0Sstevel@tonic-gate recnum)) {
251*0Sstevel@tonic-gate --count;
252*0Sstevel@tonic-gate ret = DB_SUCCESS;
253*0Sstevel@tonic-gate } else
254*0Sstevel@tonic-gate ret = DB_NOTFOUND;
255*0Sstevel@tonic-gate WRITEUNLOCK(this, ret, "wu db_index::remove");
256*0Sstevel@tonic-gate return (ret);
257*0Sstevel@tonic-gate }
258*0Sstevel@tonic-gate
259*0Sstevel@tonic-gate /*
260*0Sstevel@tonic-gate * Add a new index entry with the given index value and location 'recnum'.
261*0Sstevel@tonic-gate * Return DB_NOTUNIQUE, if entry with identical index_value and recnum
262*0Sstevel@tonic-gate * already exists. If entry is added, return DB_SUCCESS.
263*0Sstevel@tonic-gate * Increment count of number of entries in index table and grow table
264*0Sstevel@tonic-gate * if number of entries equals size of table.
265*0Sstevel@tonic-gate * Note that a copy of index_value is made for new entry.
266*0Sstevel@tonic-gate */
267*0Sstevel@tonic-gate db_status
add(item * index_value,entryp recnum)268*0Sstevel@tonic-gate db_index::add(item* index_value, entryp recnum)
269*0Sstevel@tonic-gate {
270*0Sstevel@tonic-gate register unsigned long hval;
271*0Sstevel@tonic-gate
272*0Sstevel@tonic-gate if (index_value == NULL)
273*0Sstevel@tonic-gate return (DB_NOTUNIQUE);
274*0Sstevel@tonic-gate
275*0Sstevel@tonic-gate hval = index_value->get_hashval(case_insens);
276*0Sstevel@tonic-gate
277*0Sstevel@tonic-gate WRITELOCK(this, DB_LOCK_ERROR, "w db_index::add");
278*0Sstevel@tonic-gate if (tab == NULL) grow();
279*0Sstevel@tonic-gate
280*0Sstevel@tonic-gate db_index_entry_p fst, newbucket;
281*0Sstevel@tonic-gate unsigned long bucket;
282*0Sstevel@tonic-gate bucket = hval %table_size;
283*0Sstevel@tonic-gate fst = tab[bucket];
284*0Sstevel@tonic-gate if (fst == NULL) { /* Empty bucket */
285*0Sstevel@tonic-gate if ((newbucket = new db_index_entry(hval, index_value,
286*0Sstevel@tonic-gate recnum, tab[bucket])) == NULL) {
287*0Sstevel@tonic-gate WRITEUNLOCK(this, DB_MEMORY_LIMIT,
288*0Sstevel@tonic-gate "wu db_index::add");
289*0Sstevel@tonic-gate FATAL3("db_index::add: cannot allocate space",
290*0Sstevel@tonic-gate DB_MEMORY_LIMIT, DB_MEMORY_LIMIT);
291*0Sstevel@tonic-gate }
292*0Sstevel@tonic-gate tab[bucket] = newbucket;
293*0Sstevel@tonic-gate } else if (fst->add(&tab[bucket], case_insens,
294*0Sstevel@tonic-gate hval, index_value, recnum)) {
295*0Sstevel@tonic-gate /* do nothing */
296*0Sstevel@tonic-gate } else {
297*0Sstevel@tonic-gate WRITEUNLOCK(this, DB_NOTUNIQUE, "wu db_index::add");
298*0Sstevel@tonic-gate return (DB_NOTUNIQUE);
299*0Sstevel@tonic-gate }
300*0Sstevel@tonic-gate
301*0Sstevel@tonic-gate /* increase hash table size if number of entries equals table size */
302*0Sstevel@tonic-gate if (++count > table_size)
303*0Sstevel@tonic-gate grow();
304*0Sstevel@tonic-gate
305*0Sstevel@tonic-gate WRITEUNLOCK(this, DB_SUCCESS, "wu db_index::add");
306*0Sstevel@tonic-gate return (DB_SUCCESS);
307*0Sstevel@tonic-gate }
308*0Sstevel@tonic-gate
309*0Sstevel@tonic-gate /* ************************* pickle_index ********************* */
310*0Sstevel@tonic-gate
311*0Sstevel@tonic-gate /* Does the actual writing to/from file specific for db_index structure. */
312*0Sstevel@tonic-gate static bool_t
transfer_aux(XDR * x,pptr ip)313*0Sstevel@tonic-gate transfer_aux(XDR* x, pptr ip)
314*0Sstevel@tonic-gate {
315*0Sstevel@tonic-gate return (xdr_db_index(x, (db_index*) ip));
316*0Sstevel@tonic-gate }
317*0Sstevel@tonic-gate
318*0Sstevel@tonic-gate class pickle_index: public pickle_file {
319*0Sstevel@tonic-gate public:
pickle_index(char * f,pickle_mode m)320*0Sstevel@tonic-gate pickle_index(char *f, pickle_mode m) : pickle_file(f, m) {}
321*0Sstevel@tonic-gate
322*0Sstevel@tonic-gate /* Transfers db_index structure pointed to by dp to/from file. */
transfer(db_index * dp)323*0Sstevel@tonic-gate int transfer(db_index* dp)
324*0Sstevel@tonic-gate { return (pickle_file::transfer((pptr) dp, &transfer_aux)); }
325*0Sstevel@tonic-gate };
326*0Sstevel@tonic-gate
327*0Sstevel@tonic-gate /* Dumps this index to named file. */
328*0Sstevel@tonic-gate int
dump(char * file)329*0Sstevel@tonic-gate db_index::dump(char *file)
330*0Sstevel@tonic-gate {
331*0Sstevel@tonic-gate int ret;
332*0Sstevel@tonic-gate pickle_index f(file, PICKLE_WRITE);
333*0Sstevel@tonic-gate
334*0Sstevel@tonic-gate WRITELOCK(this, -1, "w db_index::dump");
335*0Sstevel@tonic-gate int status = f.transfer(this);
336*0Sstevel@tonic-gate
337*0Sstevel@tonic-gate if (status == 1)
338*0Sstevel@tonic-gate ret = -1; /* cannot open for write */
339*0Sstevel@tonic-gate else
340*0Sstevel@tonic-gate ret = status;
341*0Sstevel@tonic-gate WRITEUNLOCK(this, ret, "wu db_index::dump");
342*0Sstevel@tonic-gate }
343*0Sstevel@tonic-gate
344*0Sstevel@tonic-gate /*
345*0Sstevel@tonic-gate * Constructor: creates index by loading it from the specified file.
346*0Sstevel@tonic-gate * If loading fails, creates empty index.
347*0Sstevel@tonic-gate */
db_index(char * file)348*0Sstevel@tonic-gate db_index::db_index(char *file)
349*0Sstevel@tonic-gate {
350*0Sstevel@tonic-gate pickle_index f(file, PICKLE_READ);
351*0Sstevel@tonic-gate tab = NULL;
352*0Sstevel@tonic-gate table_size = count = 0;
353*0Sstevel@tonic-gate
354*0Sstevel@tonic-gate /* load new hashbuf */
355*0Sstevel@tonic-gate if (f.transfer(this) < 0) {
356*0Sstevel@tonic-gate /* Load failed; reset. */
357*0Sstevel@tonic-gate tab = NULL;
358*0Sstevel@tonic-gate table_size = count = 0;
359*0Sstevel@tonic-gate }
360*0Sstevel@tonic-gate
361*0Sstevel@tonic-gate INITRW(index);
362*0Sstevel@tonic-gate }
363*0Sstevel@tonic-gate
364*0Sstevel@tonic-gate
365*0Sstevel@tonic-gate /*
366*0Sstevel@tonic-gate * Return in 'tsize' the table_size, and 'tcount' the number of entries
367*0Sstevel@tonic-gate * in the table.
368*0Sstevel@tonic-gate */
369*0Sstevel@tonic-gate void
stats(long * tsize,long * tcount)370*0Sstevel@tonic-gate db_index::stats(long *tsize, long *tcount)
371*0Sstevel@tonic-gate {
372*0Sstevel@tonic-gate READLOCKV(this, "r db_index::stats");
373*0Sstevel@tonic-gate *tsize = table_size;
374*0Sstevel@tonic-gate *tcount = count;
375*0Sstevel@tonic-gate READUNLOCKV(this, "ru db_index::stats");
376*0Sstevel@tonic-gate }
377*0Sstevel@tonic-gate
378*0Sstevel@tonic-gate /* Print all entries in the table. */
379*0Sstevel@tonic-gate void
print()380*0Sstevel@tonic-gate db_index::print()
381*0Sstevel@tonic-gate {
382*0Sstevel@tonic-gate long i;
383*0Sstevel@tonic-gate
384*0Sstevel@tonic-gate READLOCKV(this, "r db_index::print");
385*0Sstevel@tonic-gate /* Add sanity check in case table corrupted */
386*0Sstevel@tonic-gate if (tab != NULL) {
387*0Sstevel@tonic-gate for (i = 0; i < table_size; i++) {
388*0Sstevel@tonic-gate if (tab[i] != NULL)
389*0Sstevel@tonic-gate tab[i]->print_all();
390*0Sstevel@tonic-gate }
391*0Sstevel@tonic-gate }
392*0Sstevel@tonic-gate READUNLOCKV(this, "ru db_index::print");
393*0Sstevel@tonic-gate }
394*0Sstevel@tonic-gate
395*0Sstevel@tonic-gate /*
396*0Sstevel@tonic-gate * Moves an index from an xdr index. Upon completion, original index's tab
397*0Sstevel@tonic-gate * will be NULL.
398*0Sstevel@tonic-gate */
399*0Sstevel@tonic-gate
400*0Sstevel@tonic-gate db_status
move_xdr_db_index(db_index * orig)401*0Sstevel@tonic-gate db_index::move_xdr_db_index(db_index *orig)
402*0Sstevel@tonic-gate {
403*0Sstevel@tonic-gate table_size = orig->table_size;
404*0Sstevel@tonic-gate orig->table_size = 0;
405*0Sstevel@tonic-gate count = orig->count;
406*0Sstevel@tonic-gate orig->count = 0;
407*0Sstevel@tonic-gate case_insens = orig->case_insens;
408*0Sstevel@tonic-gate tab = orig->tab;
409*0Sstevel@tonic-gate orig->tab = NULL;
410*0Sstevel@tonic-gate
411*0Sstevel@tonic-gate return (DB_SUCCESS);
412*0Sstevel@tonic-gate }
413