LCOV - code coverage report
Current view: top level - src/bin/pg_rewind - fetch.c (source / functions) Hit Total Coverage
Test: PostgreSQL 12beta2 Lines: 14 14 100.0 %
Date: 2019-06-18 07:06:57 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*-------------------------------------------------------------------------
       2             :  *
       3             :  * fetch.c
       4             :  *    Functions for fetching files from a local or remote data dir
       5             :  *
       6             :  * This file forms an abstraction of getting files from the "source".
       7             :  * There are two implementations of this interface: one for copying files
       8             :  * from a data directory via normal filesystem operations (copy_fetch.c),
       9             :  * and another for fetching files from a remote server via a libpq
      10             :  * connection (libpq_fetch.c)
      11             :  *
      12             :  *
      13             :  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
      14             :  *
      15             :  *-------------------------------------------------------------------------
      16             :  */
      17             : #include "postgres_fe.h"
      18             : 
      19             : #include <sys/stat.h>
      20             : #include <unistd.h>
      21             : 
      22             : #include "pg_rewind.h"
      23             : #include "fetch.h"
      24             : #include "file_ops.h"
      25             : #include "filemap.h"
      26             : 
      27             : void
      28          16 : fetchSourceFileList(void)
      29             : {
      30          16 :     if (datadir_source)
      31           8 :         traverse_datadir(datadir_source, &process_source_file);
      32             :     else
      33           8 :         libpqProcessFileList();
      34          16 : }
      35             : 
      36             : /*
      37             :  * Fetch all relation data files that are marked in the given data page map.
      38             :  */
      39             : void
      40          16 : executeFileMap(void)
      41             : {
      42          16 :     if (datadir_source)
      43           8 :         copy_executeFileMap(filemap);
      44             :     else
      45           8 :         libpq_executeFileMap(filemap);
      46          16 : }
      47             : 
      48             : /*
      49             :  * Fetch a single file into a malloc'd buffer. The file size is returned
      50             :  * in *filesize. The returned buffer is always zero-terminated, which is
      51             :  * handy for text files.
      52             :  */
      53             : char *
      54          34 : fetchFile(const char *filename, size_t *filesize)
      55             : {
      56          34 :     if (datadir_source)
      57          18 :         return slurpFile(datadir_source, filename, filesize);
      58             :     else
      59          16 :         return libpqGetFile(filename, filesize);
      60             : }

Generated by: LCOV version 1.13