Bug-fix
authorSebastian Hammer <quinn@indexdata.com>
Wed, 20 Mar 1996 13:29:11 +0000 (13:29 +0000)
committerSebastian Hammer <quinn@indexdata.com>
Wed, 20 Mar 1996 13:29:11 +0000 (13:29 +0000)
bfile/mfile.c
isam/memory.c
isam/physical.c

index 7d81a98..6dd5fa1 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: mfile.c,v $
- * Revision 1.16  1995-12-12 15:57:57  adam
+ * Revision 1.17  1996-03-20 13:29:11  quinn
+ * Bug-fix
+ *
+ * Revision 1.16  1995/12/12  15:57:57  adam
  * Implemented mf_unlink. cf_unlink uses mf_unlink.
  *
  * Revision 1.15  1995/12/08  16:21:14  adam
@@ -402,7 +405,6 @@ int mf_write(MFile mf, int no, int offset, int num, const void *buf)
     /* file needs to grow */
     while (ps >= mf->files[mf->cur_file].blocks)
     {
-       logf (LOG_DEBUG, "File grows");
        /* file overflow - allocate new file */
        if (mf->files[mf->cur_file].dir->max_bytes >= 0 &&
            (ps - mf->files[mf->cur_file].blocks + 1) * mf->blocksize >
index b57d2f9..027b72c 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: memory.c,v $
- * Revision 1.12  1996-03-11 14:52:23  quinn
+ * Revision 1.13  1996-03-20 13:29:16  quinn
+ * Bug-fix
+ *
+ * Revision 1.12  1996/03/11  14:52:23  quinn
  * Fixed update bug. Repeated insertion in the same area sometimes caused
  * problems.
  *
@@ -307,7 +310,9 @@ int is_m_write_record(is_mtable *tab, const void *rec)
        mbuf = tab->cur_mblock->cur_mbuf = mbuf->next;
        mbuf->cur_record = 0;
     }
+    /*
     logf (LOG_DEBUG, "is_m_write_rec(rec == %d)", mbuf->cur_record);
+    */
     memcpy(mbuf->data + mbuf->offset + mbuf->cur_record * is_keysize(tab->is),
        rec, is_keysize(tab->is));
     mbuf->num++;
index d8883f1..ce4526f 100644 (file)
@@ -4,7 +4,10 @@
  * Sebastian Hammer, Adam Dickmeiss
  *
  * $Log: physical.c,v $
- * Revision 1.10  1996-03-19 19:22:44  quinn
+ * Revision 1.11  1996-03-20 13:29:17  quinn
+ * Bug-fix
+ *
+ * Revision 1.10  1996/03/19  19:22:44  quinn
  * Fixed update-bug
  *
  * Revision 1.9  1996/02/06  10:19:57  quinn
@@ -116,6 +119,9 @@ int is_p_read_partial(is_mtable *tab, is_mblock *block)
            sizeof(tab->num_records));
        buf->offset +=sizeof(tab->num_records);
     }
+    logf(LOG_DEBUG, "R: Block #%d: num %d nextpos %d total %d",
+        block->diskpos, block->num_records, block->nextpos,
+       block == tab->data ? tab->num_records : -1);
     buf->num = (toread - buf->offset) / is_keysize(tab->is);
     if (buf->num >= block->num_records)
     {
@@ -207,10 +213,14 @@ void is_p_sync(is_mtable *tab)
                sizeof(tab->num_records));
            sum += sizeof(tab->num_records);
        }
+       logf (LOG_DEBUG, "W: Block #%d contains %d records.", p->diskpos,
+           p->num_records);
        for (b = p->data; b; b = b->next)
        {
-           memcpy(type->dbuf + sum, b->data + b->offset, v = b->num *
-               is_keysize(tab->is));
+            logf(LOG_DEBUG, "   buf: offset %d, keys %d, type %d, ref %d",
+               b->offset, b->num, b->type, b->refcount);
+           if ((v = b->num * is_keysize(tab->is)) > 0)
+               memcpy(type->dbuf + sum, b->data + b->offset, v);
 
            sum += v;
            assert(sum <= type->blocksize);
@@ -220,7 +230,6 @@ void is_p_sync(is_mtable *tab)
            logf (LOG_FATAL, "Failed to write block.");
            exit(1);
        }
-       logf (LOG_DEBUG, "W: Block #%d contains %d records.", p->diskpos, p->num_records);
     }
 }
 
@@ -300,8 +309,7 @@ void is_p_align(is_mtable *tab)
            }
            else
            {
-               tab->data = tab->data->next;
-               next = tab->data;
+               next = tab->data->next;
                if (next)
                {
                    if (next->state < IS_MBSTATE_CLEAN)
@@ -320,6 +328,7 @@ void is_p_align(is_mtable *tab)
                        }
                    }
                    next->state = IS_MBSTATE_DIRTY; /* force re-process */
+                   tab->data = next;
                }
            }
            if (mblock->diskpos >= 0)