projects
/
idzebra-moved-to-github.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
a3
[idzebra-moved-to-github.git]
/
isam
/
physical.c
diff --git
a/isam/physical.c
b/isam/physical.c
index
312d3e2
..
9dccb47
100644
(file)
--- a/
isam/physical.c
+++ b/
isam/physical.c
@@
-4,7
+4,13
@@
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: physical.c,v $
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: physical.c,v $
- * Revision 1.5 1994-09-28 11:29:33 quinn
+ * Revision 1.7 1995-12-06 14:48:27 quinn
+ * Fixed some strange bugs.
+ *
+ * Revision 1.6 1995/09/04 12:33:47 adam
+ * Various cleanup. YAZ util used instead.
+ *
+ * Revision 1.5 1994/09/28 11:29:33 quinn
* Added cmp parameter.
*
* Revision 1.4 1994/09/27 20:03:53 quinn
* Added cmp parameter.
*
* Revision 1.4 1994/09/27 20:03:53 quinn
@@
-26,6
+32,7
@@
*/
#include <assert.h>
*/
#include <assert.h>
+#include <stdio.h>
#include <isam.h>
#include <isam.h>
@@
-39,14
+46,14
@@
static int is_freestore_alloc(ISAM is, int type)
if (bf_read(is->types[type].bf, tmp, 0, sizeof(tmp),
&is->types[type].freelist) <=0)
{
if (bf_read(is->types[type].bf, tmp, 0, sizeof(tmp),
&is->types[type].freelist) <=0)
{
- log(LOG_FATAL, "Failed to allocate block");
+ logf (LOG_FATAL, "Failed to allocate block");
exit(1);
}
}
else
tmp = is->types[type].top++;
exit(1);
}
}
else
tmp = is->types[type].top++;
- log(LOG_DEBUG, "Allocating block #%d", tmp);
+ logf (LOG_DEBUG, "Allocating block #%d", tmp);
return tmp;
}
return tmp;
}
@@
-54,12
+61,12
@@
static void is_freestore_free(ISAM is, int type, int block)
{
int tmp;
{
int tmp;
- log(LOG_DEBUG, "Releasing block #%d", block);
+ logf (LOG_DEBUG, "Releasing block #%d", block);
tmp = is->types[type].freelist;
is->types[type].freelist = block;
if (bf_write(is->types[type].bf, block, 0, sizeof(tmp), &tmp) < 0)
{
tmp = is->types[type].freelist;
is->types[type].freelist = block;
if (bf_write(is->types[type].bf, block, 0, sizeof(tmp), &tmp) < 0)
{
- log(LOG_FATAL, "Failed to deallocate block.");
+ logf (LOG_FATAL, "Failed to deallocate block.");
exit(1);
}
}
exit(1);
}
}
@@
-83,7
+90,7
@@
int is_p_read_partial(is_mtable *tab, is_mblock *block)
if (bf_read(tab->is->types[tab->pos_type].bf, block->diskpos, 0, toread,
buf->data) < 0)
{
if (bf_read(tab->is->types[tab->pos_type].bf, block->diskpos, 0, toread,
buf->data) < 0)
{
- log(LOG_FATAL, "bfread failed.");
+ logf (LOG_FATAL, "bfread failed.");
return -1;
}
/* extract header info */
return -1;
}
/* extract header info */
@@
-117,7
+124,7
@@
int is_p_read_full(is_mtable *tab, is_mblock *block)
if (block->state == IS_MBSTATE_UNREAD && is_p_read_partial(tab, block) < 0)
{
if (block->state == IS_MBSTATE_UNREAD && is_p_read_partial(tab, block) < 0)
{
- log(LOG_FATAL, "partial read failed.");
+ logf (LOG_FATAL, "partial read failed.");
return -1;
}
if (block->state == IS_MBSTATE_PARTIAL)
return -1;
}
if (block->state == IS_MBSTATE_PARTIAL)
@@
-136,7
+143,7
@@
int is_p_read_full(is_mtable *tab, is_mblock *block)
if (bf_read(tab->is->types[tab->pos_type].bf, block->diskpos, block->bread, toread *
is_keysize(tab->is), buf->data) < 0)
{
if (bf_read(tab->is->types[tab->pos_type].bf, block->diskpos, block->bread, toread *
is_keysize(tab->is), buf->data) < 0)
{
- log(LOG_FATAL, "bfread failed.");
+ logf (LOG_FATAL, "bfread failed.");
return -1;
}
buf->offset = 0;
return -1;
}
buf->offset = 0;
@@
-144,8
+151,9
@@
int is_p_read_full(is_mtable *tab, is_mblock *block)
dread += toread;
block->bread += toread * is_keysize(tab->is);
}
dread += toread;
block->bread += toread * is_keysize(tab->is);
}
+ block->state = IS_MBSTATE_CLEAN;
}
}
- log(LOG_DEBUG, "R: Block #%d contains %d records.", block->diskpos, block->num_records);
+ logf (LOG_DEBUG, "R: Block #%d contains %d records.", block->diskpos, block->num_records);
return 0;
}
return 0;
}
@@
-198,10
+206,10
@@
void is_p_sync(is_mtable *tab)
}
if (bf_write(type->bf, p->diskpos, 0, sum, type->dbuf) < 0)
{
}
if (bf_write(type->bf, p->diskpos, 0, sum, type->dbuf) < 0)
{
- log(LOG_FATAL, "Failed to write block.");
+ logf (LOG_FATAL, "Failed to write block.");
exit(1);
}
exit(1);
}
- log(LOG_DEBUG, "W: Block #%d contains %d records.", p->diskpos, p->num_records);
+ logf (LOG_DEBUG, "W: Block #%d contains %d records.", p->diskpos, p->num_records);
}
}
}
}
@@
-265,7
+273,7
@@
void is_p_align(is_mtable *tab)
is_mbuf *mbufs, *mbp;
int blocks, recsblock;
is_mbuf *mbufs, *mbp;
int blocks, recsblock;
- log(LOG_DEBUG, "Realigning table.");
+ logf (LOG_DEBUG, "Realigning table.");
for (mblock = tab->data; mblock; mblock = next)
{
next = mblock->next;
for (mblock = tab->data; mblock; mblock = next)
{
next = mblock->next;
@@
-336,14
+344,14
@@
void is_p_remap(is_mtable *tab)
is_mblock *blockp, **blockpp;
int recsblock, blocks;
is_mblock *blockp, **blockpp;
int recsblock, blocks;
- log(LOG_DEBUG, "Remapping table.");
+ logf (LOG_DEBUG, "Remapping table.");
/* collect all data */
bufpp = &mbufs;
for (blockp = tab->data; blockp; blockp = blockp->next)
{
if (blockp->state < IS_MBSTATE_CLEAN && is_m_read_full(tab, blockp) < 0)
{
/* collect all data */
bufpp = &mbufs;
for (blockp = tab->data; blockp; blockp = blockp->next)
{
if (blockp->state < IS_MBSTATE_CLEAN && is_m_read_full(tab, blockp) < 0)
{
- log(LOG_FATAL, "Read-full failed in remap.");
+ logf (LOG_FATAL, "Read-full failed in remap.");
exit(1);
}
*bufpp = blockp->data;
exit(1);
}
*bufpp = blockp->data;