From 235f05dc6a1fcb99e4cfb6f9d6a3ca8bc5c392db Mon Sep 17 00:00:00 2001
From: jian he <jian.universality@gmail.com>
Date: Fri, 27 Jun 2025 11:59:31 +0800
Subject: [PATCH v1 1/1] fix pg_restore not restore comments

in pg_restore, if --no-policies is specified, then there's no need to restore
comments on policies either.
---
 src/bin/pg_dump/pg_backup_archiver.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/bin/pg_dump/pg_backup_archiver.c b/src/bin/pg_dump/pg_backup_archiver.c
index 197c1295d93..d81e392a832 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -3020,6 +3020,14 @@ _tocEntryRequired(TocEntry *te, teSection curSection, ArchiveHandle *AH)
 		 strcmp(te->desc, "ROW SECURITY") == 0))
 		return 0;
 
+	/*
+	 * If --no-policies is specified, there's no need to restore comments on
+	 * policies either.
+	*/
+	if (ropt->no_policies && (strcmp(te->desc, "COMMENT") == 0) &&
+		(strncmp(te->tag, "POLICY", strlen("POLICY")) == 0))
+		return 0;
+
 	/*
 	 * If it's a publication or a table part of a publication, maybe ignore
 	 * it.
-- 
2.34.1

