agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 08/11] Rewrite nonce generation.
6+ messages / 6 participants
[nested] [flat]

* [PATCH 08/11] Rewrite nonce generation.
@ 2016-12-07 13:24 Heikki Linnakangas <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Heikki Linnakangas @ 2016-12-07 13:24 UTC (permalink / raw)

In the server, the nonce was generated using only ASCII-printable
characters, and the result was base64-encoded. The base64 encoding is
pointless, if we use only ASCII-printable chars to begin with.

Calling pg_strong_random() can be somewhat expensive, as with the
/dev/urandom implementation, it has to open the device, read the bytes,
and close, on every call. So avoid calling it in a loop, generating only
one byte in each call.

I went back to using base64-encoding method of turning the raw bytes into
the final nonce. That was more convenient than writing something that
encodes to the whole ASCII-printable range. That means that we're not using
the whole range of chars allowed in the nonce, but I believe that doesn't
make any difference. (Both the frontend and backend will still accept the
full range from the other side of the connection).
---
 src/backend/libpq/auth-scram.c       | 52 ++++++++-----------------------
 src/include/common/scram-common.h    |  6 +++-
 src/include/libpq/libpq-be.h         |  2 --
 src/interfaces/libpq/fe-auth-scram.c | 60 ++++++++++--------------------------
 4 files changed, 34 insertions(+), 86 deletions(-)

diff --git a/src/backend/libpq/auth-scram.c b/src/backend/libpq/auth-scram.c
index 55c5efa..cda663b 100644
--- a/src/backend/libpq/auth-scram.c
+++ b/src/backend/libpq/auth-scram.c
@@ -72,7 +72,7 @@ typedef struct
 
 	/* Server-side status fields */
 	char	   *server_first_message;
-	char	   *server_nonce;		/* base64-encoded */
+	char	   *server_nonce;
 	char	   *server_signature;
 } scram_state;
 
@@ -115,7 +115,6 @@ static bool verify_client_proof(scram_state *state);
 static bool verify_final_nonce(scram_state *state);
 static bool parse_scram_verifier(const char *verifier, char **salt,
 				 int *iterations, char **stored_key, char **server_key);
-static void generate_nonce(char *out, int len);
 
 /*
  * build_error_message
@@ -237,29 +236,6 @@ check_client_data(void *opaque, char **logdetail)
 	char   *passwd;
 	TimestampTz vuntil = 0;
 	bool	vuntil_null;
-	int		count = 0;
-
-	/* compute the salt to use for computing responses */
-	while (count < sizeof(MyProcPort->SASLSalt))
-	{
-		char	byte;
-
-		if (!pg_backend_random(&byte, 1))
-		{
-			*logdetail = psprintf(_("Could not generate random salt"));
-			return SASL_OTHER_ERROR;
-		}
-
-		/*
-		 * Only ASCII printable characters, except commas are accepted in
-		 * the nonce.
-		 */
-		if (byte < '!' || byte > '~' || byte == ',')
-			continue;
-
-		MyProcPort->SASLSalt[count] = byte;
-		count++;
-	}
 
 	/*
 	 * Fetch details about role needed for password checks.
@@ -450,7 +426,7 @@ scram_build_verifier(const char *username, const char *password,
 	if (iterations <= 0)
 		iterations = SCRAM_ITERATIONS_DEFAULT;
 
-	generate_nonce(salt, SCRAM_SALT_LEN);
+	pg_backend_random(salt, SCRAM_SALT_LEN);
 
 	encoded_salt = palloc(pg_b64_enc_len(SCRAM_SALT_LEN) + 1);
 	encoded_len = pg_b64_encode(salt, SCRAM_SALT_LEN, encoded_salt);
@@ -806,9 +782,6 @@ verify_client_proof(scram_state *state)
 static char *
 build_server_first_message(scram_state *state)
 {
-	char		nonce[SCRAM_NONCE_LEN];
-	int			encoded_len;
-
 	/*
 	 * server-first-message =
 	 *                   [reserved-mext ","] nonce "," salt ","
@@ -830,10 +803,19 @@ build_server_first_message(scram_state *state)
 	 *
 	 * r=fyko+d2lbbFgONRv9qkxdawL3rfcNHYJY1ZVvWVs7j,s=QSXCR+Q6sek8bf92,i=4096
 	 */
-	generate_nonce(nonce, SCRAM_NONCE_LEN);
+
+	/*
+	 * Per the spec, the nonce may consist of any printable ASCII characters.
+	 * For convenience, however, we don't use the whole range available, rather,
+	 * we generate some random bytes, and base64 encode them.
+	 */
+	char		raw_nonce[SCRAM_NONCE_LEN];
+	int			encoded_len;
+
+	pg_backend_random(raw_nonce, SCRAM_NONCE_LEN);
 
 	state->server_nonce = palloc(pg_b64_enc_len(SCRAM_NONCE_LEN) + 1);
-	encoded_len = pg_b64_encode(nonce, SCRAM_NONCE_LEN, state->server_nonce);
+	encoded_len = pg_b64_encode(raw_nonce, SCRAM_NONCE_LEN, state->server_nonce);
 
 	if (encoded_len < 0)
 		return NULL;
@@ -964,11 +946,3 @@ build_server_final_message(scram_state *state)
 	 */
 	return psprintf("v=%s", server_signature_base64);
 }
-
-static void
-generate_nonce(char *result, int len)
-{
-	/* Use the salt generated for SASL authentication */
-	memset(result, 0, len);
-	memcpy(result, MyProcPort->SASLSalt, Min(sizeof(MyProcPort->SASLSalt), len));
-}
diff --git a/src/include/common/scram-common.h b/src/include/common/scram-common.h
index e9028fb..34c6527 100644
--- a/src/include/common/scram-common.h
+++ b/src/include/common/scram-common.h
@@ -21,7 +21,11 @@
 /* length of HMAC */
 #define SHA256_HMAC_B				PG_SHA256_BLOCK_LENGTH
 
-/* length of random nonce generated in the authentication exchange */
+/*
+ * Size of random nonce generated in the authentication exchange. This is
+ * in "raw" number of bytes, the actual nonces sent over the wire are
+ * encoded using only ASCII-printable characters.
+ */
 #define SCRAM_NONCE_LEN				10
 
 /* length of salt when generating new verifiers */
diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h
index 299aaca..66647ad 100644
--- a/src/include/libpq/libpq-be.h
+++ b/src/include/libpq/libpq-be.h
@@ -144,8 +144,6 @@ typedef struct Port
 	 * Information that needs to be held during the authentication cycle.
 	 */
 	HbaLine    *hba;
-    char		SASLSalt[10];	/* SASL password salt, size of
-								 * SCRAM_SALT_LEN */
 
 	/*
 	 * Information that really has no business at all being in struct Port,
diff --git a/src/interfaces/libpq/fe-auth-scram.c b/src/interfaces/libpq/fe-auth-scram.c
index a1dc7f1..12884e5 100644
--- a/src/interfaces/libpq/fe-auth-scram.c
+++ b/src/interfaces/libpq/fe-auth-scram.c
@@ -61,7 +61,6 @@ static char *build_client_first_message(fe_scram_state *state,
 static char *build_client_final_message(fe_scram_state *state,
 										PQExpBuffer errormessage);
 static bool verify_server_proof(fe_scram_state *state);
-static bool generate_nonce(char *buf, int len);
 static void calculate_client_proof(fe_scram_state *state,
 					const char *client_final_message_without_proof,
 					uint8 *result);
@@ -257,25 +256,35 @@ read_attr_value(char **input, char attr, PQExpBuffer errorMessage)
 static char *
 build_client_first_message(fe_scram_state *state, PQExpBuffer errormessage)
 {
-	char		nonce[SCRAM_NONCE_LEN + 1];
+	char		raw_nonce[SCRAM_NONCE_LEN + 1];
 	char	   *buf;
-	char		msglen;
+	char		buflen;
+	int			n;
+	int			encoded_len;
 
-	if (!generate_nonce(nonce, SCRAM_NONCE_LEN))
+	/* XXX: Check max length of username? */
+
+	/*
+	 * Generate a "raw" nonce. This is converted to ASCII-printable form by
+	 * base64-encoding it.
+	 */
+	if (!pg_strong_random(raw_nonce, SCRAM_NONCE_LEN))
 	{
 		printfPQExpBuffer(errormessage, libpq_gettext("failed to generate nonce\n"));
 		return NULL;
 	}
 
 	/* Generate message */
-	msglen = 5 + strlen(state->username) + 3 + strlen(nonce);
-	buf = malloc(msglen + 1);
+	buflen = 5 + strlen(state->username) + 3 + pg_b64_enc_len(SCRAM_NONCE_LEN) + 1;
+	buf = malloc(buflen);
 	if (buf == NULL)
 	{
 		printfPQExpBuffer(errormessage, libpq_gettext("out of memory\n"));
 		return NULL;
 	}
-	snprintf(buf, msglen + 1, "n,,n=%s,r=%s", state->username, nonce);
+	n = snprintf(buf, buflen, "n,,n=%s,r=", state->username);
+	encoded_len = pg_b64_encode(raw_nonce, SCRAM_NONCE_LEN, buf + n);
+	buf[n + encoded_len] = '\0';
 
 	state->client_first_message_bare = strdup(buf + 3);
 	if (!state->client_first_message_bare)
@@ -527,40 +536,3 @@ verify_server_proof(fe_scram_state *state)
 
 	return true;
 }
-
-/*
- * Generate nonce with some randomness.
- * Returns true of nonce has been succesfully generated, and false
- * otherwise.
- */
-static bool
-generate_nonce(char *buf, int len)
-{
-	int		count = 0;
-
-	/* compute the salt to use for computing responses */
-	while (count < len)
-	{
-		char	byte;
-
-#ifdef HAVE_STRONG_RANDOM
-		if (!pg_strong_random(&byte, 1))
-			return false;
-#else
-		byte = random() % 256;
-#endif
-
-		/*
-		 * Only ASCII printable characters, except commas are accepted in
-		 * the nonce.
-		 */
-		if (byte < '!' || byte > '~' || byte == ',')
-			continue;
-
-		buf[count] = byte;
-		count++;
-	}
-
-	buf[len] = '\0';
-	return true;
-}
-- 
2.10.2


--------------0DD988856548A7EC1968AEA8
Content-Type: text/x-patch;
 name="0009-Random-number-fixes.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="0009-Random-number-fixes.patch"



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* [PATCH v56 5/6] Remove the GUC stats_temp_directory
@ 2020-09-29 13:59 Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Kyotaro Horiguchi @ 2020-09-29 13:59 UTC (permalink / raw)

The new stats collection system doesn't need temporary directory, so
just remove it. pg_stat_statements modified to use pg_stat directory
to store its temporary files.  As the result basebackup copies the
pg_stat_statments' temporary file if exists.
---
 .../pg_stat_statements/pg_stat_statements.c   | 13 +++---
 doc/src/sgml/backup.sgml                      |  2 -
 doc/src/sgml/config.sgml                      | 19 --------
 doc/src/sgml/storage.sgml                     |  6 ---
 src/backend/postmaster/pgstat.c               | 10 -----
 src/backend/replication/basebackup.c          | 36 ----------------
 src/backend/utils/misc/guc.c                  | 43 -------------------
 src/backend/utils/misc/postgresql.conf.sample |  1 -
 src/bin/initdb/initdb.c                       |  1 -
 src/bin/pg_rewind/filemap.c                   |  7 ---
 src/include/pgstat.h                          |  3 --
 src/test/perl/PostgresNode.pm                 |  4 --
 12 files changed, 6 insertions(+), 139 deletions(-)

diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 62cccbfa44..28279f97d5 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -89,14 +89,13 @@ PG_MODULE_MAGIC;
 #define PGSS_DUMP_FILE	PGSTAT_STAT_PERMANENT_DIRECTORY "/pg_stat_statements.stat"
 
 /*
- * Location of external query text file.  We don't keep it in the core
- * system's stats_temp_directory.  The core system can safely use that GUC
- * setting, because the statistics collector temp file paths are set only once
- * as part of changing the GUC, but pg_stat_statements has no way of avoiding
- * race conditions.  Besides, we only expect modest, infrequent I/O for query
- * strings, so placing the file on a faster filesystem is not compelling.
+ * Location of external query text file.  We don't keep it in the core system's
+ * pg_stats.  pg_stat_statements has no way of avoiding race conditions even if
+ * the directory were specified by a GUC.  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_DIR "/pgss_query_texts.stat"
+#define PGSS_TEXT_FILE	PGSTAT_STAT_PERMANENT_DIRECTORY "/pgss_query_texts.stat"
 
 /* Magic number identifying the stats file format */
 static const uint32 PGSS_FILE_HEADER = 0x20201218;
diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml
index c5557d5444..875769a57e 100644
--- a/doc/src/sgml/backup.sgml
+++ b/doc/src/sgml/backup.sgml
@@ -1155,8 +1155,6 @@ SELECT pg_stop_backup();
     <filename>pg_snapshots/</filename>, <filename>pg_stat_tmp/</filename>,
     and <filename>pg_subtrans/</filename> (but not the directories themselves) can be
     omitted from the backup as they will be initialized on postmaster startup.
-    If <xref linkend="guc-stats-temp-directory"/> is set and is under the data
-    directory then the contents of that directory can also be omitted.
    </para>
 
    <para>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 53d7dfda93..9a749447ec 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -7509,25 +7509,6 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
       </listitem>
      </varlistentry>
 
-     <varlistentry id="guc-stats-temp-directory" xreflabel="stats_temp_directory">
-      <term><varname>stats_temp_directory</varname> (<type>string</type>)
-      <indexterm>
-       <primary><varname>stats_temp_directory</varname> configuration parameter</primary>
-      </indexterm>
-      </term>
-      <listitem>
-       <para>
-        Sets the directory to store temporary statistics data in. This can be
-        a path relative to the data directory or an absolute path. The default
-        is <filename>pg_stat_tmp</filename>. Pointing this at a RAM-based
-        file system will decrease physical I/O requirements and can lead to
-        improved performance.
-        This parameter can only be set in the <filename>postgresql.conf</filename>
-        file or on the server command line.
-       </para>
-      </listitem>
-     </varlistentry>
-
      </variablelist>
     </sect2>
 
diff --git a/doc/src/sgml/storage.sgml b/doc/src/sgml/storage.sgml
index 3234adb639..6bac5e075e 100644
--- a/doc/src/sgml/storage.sgml
+++ b/doc/src/sgml/storage.sgml
@@ -120,12 +120,6 @@ Item
   subsystem</entry>
 </row>
 
-<row>
- <entry><filename>pg_stat_tmp</filename></entry>
- <entry>Subdirectory containing temporary files for the statistics
-  subsystem</entry>
-</row>
-
 <row>
  <entry><filename>pg_subtrans</filename></entry>
  <entry>Subdirectory containing subtransaction status data</entry>
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 575ecdd502..c09fa026b9 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -99,16 +99,6 @@ bool		pgstat_track_counts = false;
 int			pgstat_track_functions = TRACK_FUNC_OFF;
 int			pgstat_track_activity_query_size = 1024;
 
-/* ----------
- * Built from GUC parameter
- * ----------
- */
-char      *pgstat_stat_directory = NULL;
-
-/* No longer used, but will be removed with GUC */
-char      *pgstat_stat_filename = NULL;
-char      *pgstat_stat_tmpname = NULL;
-
 /*
  * WAL usage counters saved from pgWALUsage at the previous call to
  * pgstat_report_wal(). This is used to calculate how much WAL usage
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index fa7bdbcefa..f0d75f55bd 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -87,9 +87,6 @@ static int	basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset,
 /* 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.
  */
@@ -152,13 +149,6 @@ struct exclude_list_item
  */
 static const char *const excludeDirContents[] =
 {
-	/*
-	 * 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.
-	 */
-	PG_STAT_TMP_DIR,
-
 	/*
 	 * It is generally not useful to backup the contents of this directory
 	 * even if the intention is to restore to another primary. See backup.sgml
@@ -261,7 +251,6 @@ perform_base_backup(basebackup_options *opt)
 	StringInfo	labelfile;
 	StringInfo	tblspc_map_file;
 	backup_manifest_info manifest;
-	int			datadirpathlen;
 	List	   *tablespaces = NIL;
 
 	backup_total = 0;
@@ -284,8 +273,6 @@ perform_base_backup(basebackup_options *opt)
 	Assert(CurrentResourceOwner == NULL);
 	CurrentResourceOwner = ResourceOwnerCreate(NULL, "base backup");
 
-	datadirpathlen = strlen(DataDir);
-
 	backup_started_in_recovery = RecoveryInProgress();
 
 	labelfile = makeStringInfo();
@@ -314,18 +301,6 @@ perform_base_backup(basebackup_options *opt)
 		tablespaceinfo *ti;
 		int			tblspc_streamed = 0;
 
-		/*
-		 * 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;
-
 		/* Add a node for the base directory at the end */
 		ti = palloc0(sizeof(tablespaceinfo));
 		ti->size = -1;
@@ -1377,17 +1352,6 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
 		if (excludeFound)
 			continue;
 
-		/*
-		 * Exclude contents of directory specified by statrelpath if not set
-		 * to the default (pg_stat_tmp) which is caught in the loop above.
-		 */
-		if (statrelpath != NULL && strcmp(pathbuf, statrelpath) == 0)
-		{
-			elog(DEBUG1, "contents of directory \"%s\" excluded from backup", statrelpath);
-			size += _tarWriteDir(pathbuf, basepathlen, &statbuf, sizeonly);
-			continue;
-		}
-
 		/*
 		 * We can skip pg_wal, the WAL segments need to be fetched from the
 		 * WAL archive anyway. But include it as an empty directory anyway, so
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index b22fa6b86e..99bca927ce 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -203,7 +203,6 @@ static bool check_autovacuum_work_mem(int *newval, void **extra, GucSource sourc
 static bool check_effective_io_concurrency(int *newval, void **extra, GucSource source);
 static bool check_maintenance_io_concurrency(int *newval, void **extra, GucSource source);
 static bool check_huge_page_size(int *newval, void **extra, GucSource source);
-static void assign_pgstat_temp_directory(const char *newval, void *extra);
 static bool check_application_name(char **newval, void **extra, GucSource source);
 static void assign_application_name(const char *newval, void *extra);
 static bool check_cluster_name(char **newval, void **extra, GucSource source);
@@ -560,8 +559,6 @@ char	   *HbaFileName;
 char	   *IdentFileName;
 char	   *external_pid_file;
 
-char	   *pgstat_temp_directory;
-
 char	   *application_name;
 
 int			tcp_keepalives_idle;
@@ -4365,17 +4362,6 @@ static struct config_string ConfigureNamesString[] =
 		NULL, NULL, NULL
 	},
 
-	{
-		{"stats_temp_directory", PGC_SIGHUP, STATS_ACTIVITY,
-			gettext_noop("Writes temporary statistics files to the specified directory."),
-			NULL,
-			GUC_SUPERUSER_ONLY
-		},
-		&pgstat_temp_directory,
-		PG_STAT_TMP_DIR,
-		check_canonical_path, assign_pgstat_temp_directory, NULL
-	},
-
 	{
 		{"synchronous_standby_names", PGC_SIGHUP, REPLICATION_PRIMARY,
 			gettext_noop("Number of synchronous standbys and list of names of potential synchronous ones."),
@@ -11781,35 +11767,6 @@ check_huge_page_size(int *newval, void **extra, GucSource source)
 	return true;
 }
 
-static void
-assign_pgstat_temp_directory(const char *newval, void *extra)
-{
-	/* check_canonical_path already canonicalized newval for us */
-	char	   *dname;
-	char	   *tname;
-	char	   *fname;
-
-	/* directory */
-	dname = guc_malloc(ERROR, strlen(newval) + 1);	/* runtime dir */
-	sprintf(dname, "%s", newval);
-
-	/* global stats */
-	tname = guc_malloc(ERROR, strlen(newval) + 12); /* /global.tmp */
-	sprintf(tname, "%s/global.tmp", newval);
-	fname = guc_malloc(ERROR, strlen(newval) + 13); /* /global.stat */
-	sprintf(fname, "%s/global.stat", newval);
-
-	if (pgstat_stat_directory)
-		free(pgstat_stat_directory);
-	pgstat_stat_directory = dname;
-	if (pgstat_stat_tmpname)
-		free(pgstat_stat_tmpname);
-	pgstat_stat_tmpname = tname;
-	if (pgstat_stat_filename)
-		free(pgstat_stat_filename);
-	pgstat_stat_filename = fname;
-}
-
 static bool
 check_application_name(char **newval, void **extra, GucSource source)
 {
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index b0e73024a1..92aace4208 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -589,7 +589,6 @@
 #track_wal_io_timing = off
 #track_functions = none			# none, pl, all
 #track_activity_query_size = 1024	# (change requires restart)
-#stats_temp_directory = 'pg_stat_tmp'
 
 
 # - Monitoring -
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 3c1cf78b4f..07a00b8d0d 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -219,7 +219,6 @@ static const char *const subdirs[] = {
 	"pg_replslot",
 	"pg_tblspc",
 	"pg_stat",
-	"pg_stat_tmp",
 	"pg_xact",
 	"pg_logical",
 	"pg_logical/snapshots",
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
index 2618b4c957..ab5cb51de7 100644
--- a/src/bin/pg_rewind/filemap.c
+++ b/src/bin/pg_rewind/filemap.c
@@ -87,13 +87,6 @@ struct exclude_list_item
  */
 static const char *excludeDirContents[] =
 {
-	/*
-	 * 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.
-	 */
-	"pg_stat_tmp",				/* defined as PG_STAT_TMP_DIR */
-
 	/*
 	 * It is generally not useful to backup the contents of this directory
 	 * even if the intention is to restore to another primary. See backup.sgml
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index f4177eb284..e1c54e73f2 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -33,9 +33,6 @@
 #define PGSTAT_STAT_PERMANENT_FILENAME		"pg_stat/saved_stats"
 #define PGSTAT_STAT_PERMANENT_TMPFILE		"pg_stat/saved_stats.tmp"
 
-/* Default directory to store temporary statistics data in */
-#define PG_STAT_TMP_DIR                "pg_stat_tmp"
-
 /* Values for track_functions GUC variable --- order is significant! */
 typedef enum TrackFunctionsLevel
 {
diff --git a/src/test/perl/PostgresNode.pm b/src/test/perl/PostgresNode.pm
index 9667f7667e..dd41a43b4e 100644
--- a/src/test/perl/PostgresNode.pm
+++ b/src/test/perl/PostgresNode.pm
@@ -455,10 +455,6 @@ sub init
 	print $conf TestLib::slurp_file($ENV{TEMP_CONFIG})
 	  if defined $ENV{TEMP_CONFIG};
 
-	# XXX Neutralize any stats_temp_directory in TEMP_CONFIG.  Nodes running
-	# concurrently must not share a stats_temp_directory.
-	print $conf "stats_temp_directory = 'pg_stat_tmp'\n";
-
 	if ($params{allows_streaming})
 	{
 		if ($params{allows_streaming} eq "logical")
-- 
2.27.0


----Next_Part(Tue_Mar_16_10_27_55_2021_500)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="v56-0006-Exclude-pg_stat-directory-from-base-backup.patch"



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Fix the synopsis of pg_md5_hash
@ 2024-03-14 06:02 Tatsuro Yamada <[email protected]>
  2024-03-14 08:32 ` Re: Fix the synopsis of pg_md5_hash Daniel Gustafsson <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Tatsuro Yamada @ 2024-03-14 06:02 UTC (permalink / raw)
  To: pgsql-hackers

Hi,

The synopsis of pg_md5_hash() seems wrong such as:
    - s/int/bool/
    - "errstr" is missing
So, I created a patch to fix them.

src/common/md5_common.c
==================================================
*  SYNOPSIS      #include "md5.h"
*                int pg_md5_hash(const void *buff, size_t len, char *hexsum)
...
bool
pg_md5_hash(const void *buff, size_t len, char *hexsum, const char **errstr)
==================================================

Please find attached file.

Regards,
Tatsuro Yamada
NTT Open Source Software Center



Attachments:

  [application/octet-stream] fix_synopsis_of_pg_md5_hash.patch (582B, ../../TYYPR01MB82313576150CC86084A122CD9E292@TYYPR01MB8231.jpnprd01.prod.outlook.com/2-fix_synopsis_of_pg_md5_hash.patch)
  download | inline diff:
diff --git a/src/common/md5_common.c b/src/common/md5_common.c
index 094878479c..c654efe971 100644
--- a/src/common/md5_common.c
+++ b/src/common/md5_common.c
@@ -45,7 +45,8 @@ bytesToHex(uint8 b[16], char *s)
  *	Calculates the MD5 sum of the bytes in a buffer.
  *
  *	SYNOPSIS	  #include "md5.h"
- *				  int pg_md5_hash(const void *buff, size_t len, char *hexsum)
+ *				  bool pg_md5_hash(const void *buff, size_t len, char *hexsum,
+ *				                   const char **errstr)
  *
  *	INPUT		  buff	  the buffer containing the bytes that you want
  *						  the MD5 sum of.


^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Fix the synopsis of pg_md5_hash
  2024-03-14 06:02 Fix the synopsis of pg_md5_hash Tatsuro Yamada <[email protected]>
@ 2024-03-14 08:32 ` Daniel Gustafsson <[email protected]>
  2024-03-14 22:59   ` Re: Fix the synopsis of pg_md5_hash Michael Paquier <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Daniel Gustafsson @ 2024-03-14 08:32 UTC (permalink / raw)
  To: Tatsuro Yamada <[email protected]>; +Cc: pgsql-hackers

> On 14 Mar 2024, at 07:02, Tatsuro Yamada <[email protected]> wrote:

> So, I created a patch to fix them.

Thanks, applied.

--
Daniel Gustafsson







^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Fix the synopsis of pg_md5_hash
  2024-03-14 06:02 Fix the synopsis of pg_md5_hash Tatsuro Yamada <[email protected]>
  2024-03-14 08:32 ` Re: Fix the synopsis of pg_md5_hash Daniel Gustafsson <[email protected]>
@ 2024-03-14 22:59   ` Michael Paquier <[email protected]>
  2024-03-14 23:38     ` Re: Fix the synopsis of pg_md5_hash Tatsuro Yamada <[email protected]>
  0 siblings, 1 reply; 6+ messages in thread

From: Michael Paquier @ 2024-03-14 22:59 UTC (permalink / raw)
  To: Daniel Gustafsson <[email protected]>; +Cc: Tatsuro Yamada <[email protected]>; pgsql-hackers

On Thu, Mar 14, 2024 at 09:32:55AM +0100, Daniel Gustafsson wrote:
> On 14 Mar 2024, at 07:02, Tatsuro Yamada <[email protected]> wrote:
>> So, I created a patch to fix them.
> 
> Thanks, applied.

Oops.  Thanks.
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Fix the synopsis of pg_md5_hash
  2024-03-14 06:02 Fix the synopsis of pg_md5_hash Tatsuro Yamada <[email protected]>
  2024-03-14 08:32 ` Re: Fix the synopsis of pg_md5_hash Daniel Gustafsson <[email protected]>
  2024-03-14 22:59   ` Re: Fix the synopsis of pg_md5_hash Michael Paquier <[email protected]>
@ 2024-03-14 23:38     ` Tatsuro Yamada <[email protected]>
  0 siblings, 0 replies; 6+ messages in thread

From: Tatsuro Yamada @ 2024-03-14 23:38 UTC (permalink / raw)
  To: Michael Paquier <[email protected]>; +Cc: Daniel Gustafsson <[email protected]>; Tatsuro Yamada <[email protected]>; pgsql-hackers

Hi, Daniel and Michael,

On Thu, Mar 14, 2024 at 09:32:55AM +0100, Daniel Gustafsson wrote:
> > On 14 Mar 2024, at 07:02, Tatsuro Yamada <[email protected]> wrote:
> >> So, I created a patch to fix them.
> >
> > Thanks, applied.
>
> Oops.  Thanks.
> --
> Michael
>

Thank you guys!

Regards,
Tatsuro Yamada
NTT Open Source Software Center


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2024-03-14 23:38 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-12-07 13:24 [PATCH 08/11] Rewrite nonce generation. Heikki Linnakangas <[email protected]>
2020-09-29 13:59 [PATCH v56 5/6] Remove the GUC stats_temp_directory Kyotaro Horiguchi <[email protected]>
2024-03-14 06:02 Fix the synopsis of pg_md5_hash Tatsuro Yamada <[email protected]>
2024-03-14 08:32 ` Re: Fix the synopsis of pg_md5_hash Daniel Gustafsson <[email protected]>
2024-03-14 22:59   ` Re: Fix the synopsis of pg_md5_hash Michael Paquier <[email protected]>
2024-03-14 23:38     ` Re: Fix the synopsis of pg_md5_hash Tatsuro Yamada <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox