/* * Re-open a suspended file for reading. This allocates all the necessary * buffers and data structures to restart reading from the file */ void ExecWorkFile_Restart(ExecWorkFile *workfile) { Assert(workfile != NULL); Assert((workfile->flags & EXEC_WORKFILE_SUSPENDABLE) != 0); switch(workfile->fileType) { case BFZ: bfz_scan_begin((bfz_t *) workfile->file); break; default: insist_log(false, "invalid work file type: %d", workfile->fileType); } }
/* * Tests that bfz->freeable_stuff->tot_bytes is initialized to 0 * in bfz_scan_begin */ void test__bfz_scan_begin_initbytes(void **state) { bfz_t *bfz = palloc0(sizeof(bfz_t)); bfz->compression_index = 0; /* compress_nothing */ bfz->mode = BFZ_MODE_FREED; bfz->fd = 1; bfz_scan_begin(bfz); assert_true(bfz->mode == BFZ_MODE_SCAN); struct bfz_freeable_stuff *fs = bfz->freeable_stuff; assert_true(fs->buffer_pointer == fs->buffer_end); assert_true((void *) fs->buffer_end == (void *) fs->buffer); assert_true(fs->tot_bytes == 0L); }
/* * ExecWorkFile_Rewind * rewind the pointer position to the beginning of the file. * * This function returns true if this succeeds. Otherwise, return false. */ bool ExecWorkFile_Rewind(ExecWorkFile *workfile) { Assert(workfile != NULL); long ret = 0; int64 file_size = 0; switch(workfile->fileType) { case BUFFILE: ret = BufFileSeek((BufFile *)workfile->file, 0L /* offset */, SEEK_SET); /* BufFileSeek returns 0 if everything went OK */ return (0 == ret); case BFZ: file_size = bfz_append_end((bfz_t *)workfile->file); ExecWorkFile_AdjustBFZSize(workfile, file_size); bfz_scan_begin((bfz_t *)workfile->file); break; default: insist_log(false, "invalid work file type: %d", workfile->fileType); } return true; }