#include "parser/analyze.h"
#include "parser/parsetree.h"
#include "parser/scanner.h"
+#include "pgstat.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/spin.h"
* race conditions. Besides, we only expect modest, infrequent I/O for query
* strings, so placing the file on a faster filesystem is not compelling.
*/
-#define PGSS_TEXT_FILE "pg_stat_tmp/pgss_query_texts.stat"
+#define PGSS_TEXT_FILE PG_STAT_TMP_DIR "/pgss_query_texts.stat"
/* Magic number identifying the stats file format */
static const uint32 PGSS_FILE_HEADER = 0x20140125;
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "nodes/pg_list.h"
+#include "pgstat.h"
#include "replication/basebackup.h"
#include "replication/walsender.h"
#include "replication/walsender_private.h"
/* Was the backup currently in-progress initiated in recovery mode? */
static bool backup_started_in_recovery = false;
+/* Relative path of temporary statistics directory */
+static char *statrelpath = NULL;
+
/*
* Size of each block sent into the tar stream for larger files.
*/
&labelfile);
SendXlogRecPtrResult(startptr, starttli);
+ /*
+ * Calculate the relative path of temporary statistics directory
+ * in order to skip the files which are located in that directory later.
+ */
+ if (is_absolute_path(pgstat_stat_directory) &&
+ strncmp(pgstat_stat_directory, DataDir, datadirpathlen) == 0)
+ statrelpath = psprintf("./%s", pgstat_stat_directory + datadirpathlen + 1);
+ else if (strncmp(pgstat_stat_directory, "./", 2) != 0)
+ statrelpath = psprintf("./%s", pgstat_stat_directory);
+ else
+ statrelpath = pgstat_stat_directory;
+
PG_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
{
List *tablespaces = NIL;
sizeof(PG_AUTOCONF_FILENAME) + 4) == 0)
continue;
-
/*
* If there's a backup_label file, it belongs to a backup started by
* the user with pg_start_backup(). It is *not* correct for this
continue;
}
+ /*
+ * Skip temporary statistics files. PG_STAT_TMP_DIR must be skipped
+ * even when stats_temp_directory is set because PGSS_TEXT_FILE is
+ * always created there.
+ */
+ if ((statrelpath != NULL && strcmp(pathbuf, statrelpath) == 0) ||
+ strncmp(de->d_name, PG_STAT_TMP_DIR, strlen(PG_STAT_TMP_DIR)) == 0)
+ {
+ if (!sizeonly)
+ _tarWriteHeader(pathbuf + basepathlen + 1, NULL, &statbuf);
+ size += 512;
+ continue;
+ }
+
/*
* We can skip pg_xlog, the WAL segments need to be fetched from the
* WAL archive anyway. But include it as an empty directory anyway, so