+ if (preserve_position)
+ {
+/* section that preserve all keys */
+ heap_delete (ti);
+ if (is_readkey (ispt[n], ti->tmpbuf))
+ heap_insert (ti, ti->tmpbuf, n);
+ else
+ is_pt_free (ispt[n]);
+ }
+ else
+ {
+/* section that preserve all keys with unique sysnos */
+ while (1)
+ {
+ if (!is_readkey (ispt[n], ti->tmpbuf))
+ {
+ heap_delete (ti);
+ is_pt_free (ispt[n]);
+ break;
+ }
+ if ((*ti->cmp)(ti->tmpbuf, ti->heap[ti->ptr[1]]) > 1)
+ {
+ heap_delete (ti);
+ heap_insert (ti, ti->tmpbuf, n);
+ break;
+ }
+ }
+ }
+ }
+ heap_close (ti);
+ xfree (ispt);
+ }
+ else if (zi->reg->isamc)
+ {
+ ISAMC_PP *ispt;
+ int i;
+ struct trunc_info *ti;
+
+ ispt = (ISAMC_PP *) xmalloc (sizeof(*ispt) * (to-from));
+
+ ti = heap_init (to-from, sizeof(struct it_key),
+ key_compare_it);
+ for (i = to-from; --i >= 0; )
+ {
+ ispt[i] = isc_pp_open (zi->reg->isamc, isam_p[from+i]);
+ if (isc_pp_read (ispt[i], ti->tmpbuf))
+ heap_insert (ti, ti->tmpbuf, i);
+ else
+ isc_pp_close (ispt[i]);
+ }
+ while (ti->heapnum)
+ {
+ int n = ti->indx[ti->ptr[1]];
+
+ rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
+ if (preserve_position)
+ {
+ heap_delete (ti);
+ if (isc_pp_read (ispt[n], ti->tmpbuf))
+ heap_insert (ti, ti->tmpbuf, n);
+ else
+ isc_pp_close (ispt[n]);
+ }
+ else
+ {
+ while (1)
+ {
+ if (!isc_pp_read (ispt[n], ti->tmpbuf))
+ {
+ heap_delete (ti);
+ isc_pp_close (ispt[n]);
+ break;
+ }
+ if ((*ti->cmp)(ti->tmpbuf, ti->heap[ti->ptr[1]]) > 1)
+ {
+ heap_delete (ti);
+ heap_insert (ti, ti->tmpbuf, n);
+ break;
+ }
+ }
+ }
+ }
+ heap_close (ti);
+ xfree (ispt);
+ }
+
+ else if (zi->reg->isamd)
+ {
+ ISAMD_PP *ispt;
+ int i;
+ struct trunc_info *ti;
+
+ ispt = (ISAMD_PP *) xmalloc (sizeof(*ispt) * (to-from));
+
+ ti = heap_init (to-from, sizeof(struct it_key),
+ key_compare_it);
+ for (i = to-from; --i >= 0; )
+ {
+ ispt[i] = isamd_pp_open (zi->reg->isamd, isam_p[from+i]);
+ if (isamd_pp_read (ispt[i], ti->tmpbuf))
+ heap_insert (ti, ti->tmpbuf, i);
+ else
+ isamd_pp_close (ispt[i]);
+ }
+ while (ti->heapnum)
+ {
+ int n = ti->indx[ti->ptr[1]];
+
+ rset_write (result, result_rsfd, ti->heap[ti->ptr[1]]);
+#if 0