* BufFileLoadBuffer * * Load some data into buffer, if possible, starting from curOffset. * At call, must have dirty = false, pos and nbytes = 0. * On exit, nbytes is number of bytes loaded. */
| 596 | * On exit, nbytes is number of bytes loaded. |
| 597 | */ |
| 598 | static void |
| 599 | BufFileLoadBuffer(BufFile *file) |
| 600 | { |
| 601 | File thisfile; |
| 602 | |
| 603 | /* |
| 604 | * Advance to next component file if necessary and possible. |
| 605 | */ |
| 606 | if (file->curOffset >= MAX_PHYSICAL_FILESIZE && |
| 607 | file->curFile + 1 < file->numFiles) |
| 608 | { |
| 609 | file->curFile++; |
| 610 | file->curOffset = 0L; |
| 611 | } |
| 612 | |
| 613 | /* |
| 614 | * Read whatever we can get, up to a full bufferload. |
| 615 | */ |
| 616 | thisfile = file->files[file->curFile]; |
| 617 | file->nbytes = FileRead(thisfile, |
| 618 | file->buffer.data, |
| 619 | BLCKSZ, |
| 620 | file->curOffset, |
| 621 | WAIT_EVENT_BUFFILE_READ); |
| 622 | if (file->nbytes < 0) |
| 623 | { |
| 624 | file->nbytes = 0; |
| 625 | ereport(ERROR, |
| 626 | (errcode_for_file_access(), |
| 627 | errmsg("could not read file \"%s\": %m", |
| 628 | FilePathName(thisfile)))); |
| 629 | } |
| 630 | |
| 631 | /* we choose not to advance curOffset here */ |
| 632 | |
| 633 | if (file->nbytes > 0) |
| 634 | pgBufferUsage.temp_blks_read++; |
| 635 | } |
| 636 | |
| 637 | /* |
| 638 | * BufFileDumpBuffer |
no test coverage detected