Be more careful about time_t vs. pg_time_t in basebackup.c.
authorRobert Haas <[email protected]>
Sat, 4 Apr 2020 00:15:27 +0000 (20:15 -0400)
committerRobert Haas <[email protected]>
Sat, 4 Apr 2020 00:18:47 +0000 (20:18 -0400)
lapwing is complaining that about a call to pg_gmtime, saying that
it "expected 'const pg_time_t *' but argument is of type 'time_t *'".
I at first thought that the problem had someting to do with const,
but Thomas Munro suggested that it might be just because time_t
and pg_time_t are different identifers. lapwing is i686 rather than
x86_64, and pg_time_t is always int64, so that seems like a good
guess.

There is other code that just casts time_t to pg_time_t without
any conversion function, so try that approach here.

Introduced in commit 0d8c9c1210c44b36ec2efcb223a1dfbe897a3661.

src/backend/replication/basebackup.c

index 3b18e733cdfa16c3a4e9f2300c8f605ec743ddee..5d94b9c22911bc715f2be186f2d7942ac0b91571 100644 (file)
@@ -99,7 +99,8 @@ static void InitializeManifest(manifest_info *manifest,
                               basebackup_options *opt);
 static void AppendStringToManifest(manifest_info *manifest, char *s);
 static void AddFileToManifest(manifest_info *manifest, const char *spcoid,
-                             const char *pathname, size_t size, time_t mtime,
+                             const char *pathname, size_t size,
+                             pg_time_t mtime,
                              pg_checksum_context *checksum_ctx);
 static void AddWALInfoToManifest(manifest_info *manifest, XLogRecPtr startptr,
                                 TimeLineID starttli, XLogRecPtr endptr,
@@ -1124,7 +1125,7 @@ AppendStringToManifest(manifest_info *manifest, char *s)
  */
 static void
 AddFileToManifest(manifest_info *manifest, const char *spcoid,
-                 const char *pathname, size_t size, time_t mtime,
+                 const char *pathname, size_t size, pg_time_t mtime,
                  pg_checksum_context *checksum_ctx)
 {
    char        pathbuf[MAXPGPATH];
@@ -1507,7 +1508,8 @@ sendFileWithContent(const char *filename, const char *content,
    }
 
    pg_checksum_update(&checksum_ctx, (uint8 *) content, len);
-   AddFileToManifest(manifest, NULL, filename, len, statbuf.st_mtime,
+   AddFileToManifest(manifest, NULL, filename, len,
+                     (pg_time_t) statbuf.st_mtime,
                      &checksum_ctx);
 }
 
@@ -2188,7 +2190,7 @@ sendFile(const char *readfilename, const char *tarfilename,
    total_checksum_failures += checksum_failures;
 
    AddFileToManifest(manifest, spcoid, tarfilename, statbuf->st_size,
-                     statbuf->st_mtime, &checksum_ctx);
+                     (pg_time_t) statbuf->st_mtime, &checksum_ctx);
 
    return true;
 }