Improve comments.
authorHeikki Linnakangas <[email protected]>
Fri, 16 Jan 2015 12:16:18 +0000 (14:16 +0200)
committerHeikki Linnakangas <[email protected]>
Fri, 16 Jan 2015 12:16:18 +0000 (14:16 +0200)
Move comments out of SQL queries, into the surrounding code.

src/bin/pg_rewind/libpq_fetch.c

index 57cb6a6e706706dae100ce20c6350472dd69727e..dc1ecdd89e348ea3dbf1a10461452ada7fcde287 100644 (file)
 static PGconn *conn = NULL;
 
 /*
- * Relation files are fetched max CHUNKSIZE bytes at a time.
+ * Files are fetched max CHUNKSIZE bytes at a time.
+ *
+ * (This only applies to files that are copied in whole, or for truncated
+ * files where we copy the tail. Relation files, where we know the individual
+ * blocks that need to be fetched, are fetched in BLCKSZ chunks.)
  */
 #define CHUNKSIZE 1000000
 
@@ -131,8 +135,17 @@ libpqProcessFileList(void)
        const char *sql;
        int                     i;
 
+       /*
+        * Create a recursive directory listing of the whole data directory.
+        *
+        * The WITH RECURSIVE part does most of the work. The second part
+        * gets the targets of the symlinks in pg_tblspc directory.
+        *
+        * XXX: There is no backend function to get a symbolic link's target in
+        * general, so if the admin has put any custom symbolic links in the data
+        * directory, they won't be copied correctly.
+        */
        sql =
-               "-- Create a recursive directory listing of the whole data directory\n"
                "WITH RECURSIVE files (path, filename, size, isdir) AS (\n"
                "  SELECT '' AS path, filename, size, isdir FROM\n"
                "  (SELECT pg_ls_dir('.') AS filename) AS fn,\n"
@@ -145,13 +158,6 @@ libpqProcessFileList(void)
                "       pg_stat_file(parent.path || parent.filename || '/' || fn) AS this\n"
                "       WHERE parent.isdir = 't'\n"
                ")\n"
-               "-- Using the cte, fetch a listing of the all the files.\n"
-               "--\n"
-               "-- For tablespaces, use pg_tablespace_location() function to fetch\n"
-               "-- the link target (there is no backend function to get a symbolic\n"
-               "-- link's target in general, so if the admin has put any custom\n"
-               "-- symbolic links in the data directory, they won't be copied\n"
-               "-- correctly)\n"
                "SELECT path || filename, size, isdir,\n"
                "       pg_tablespace_location(pg_tablespace.oid) AS link_target\n"
                "FROM files\n"
@@ -420,9 +426,11 @@ libpq_executeFileMap(filemap_t *map)
                                         PQresultErrorMessage(res));
        }
 
-       /* Ok, we've sent the file list. Now receive the files. */
+       /*
+        * We've now copied the list of file ranges that we need to fetch to
+        * the temporary table. Now, actually fetch all of those ranges.
+        */
        sql =
-               "-- fetch all the blocks listed in the temp table.\n"
                "SELECT path, begin, \n"
                "  pg_read_binary_file(path, begin, len) AS chunk\n"
                "FROM fetchchunks\n";
@@ -430,7 +438,6 @@ libpq_executeFileMap(filemap_t *map)
        receiveFileChunks(sql);
 }
 
-
 static void
 execute_pagemap(datapagemap_t *pagemap, const char *path)
 {