From: Heikki Linnakangas Date: Fri, 16 Jan 2015 12:16:18 +0000 (+0200) Subject: Improve comments. X-Git-Url: http://git.postgresql.org/gitweb/static/tut_user.html?a=commitdiff_plain;h=8d232649c7ccc75d6454598d5ba1ab4af2102041;p=users%2Fheikki%2Fpostgres.git Improve comments. Move comments out of SQL queries, into the surrounding code. --- diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c index 57cb6a6e70..dc1ecdd89e 100644 --- a/src/bin/pg_rewind/libpq_fetch.c +++ b/src/bin/pg_rewind/libpq_fetch.c @@ -32,7 +32,11 @@ 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) {