public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v4 3/3] Fix timeline-tracking failure while sending a historic timeline
2+ messages / 2 participants
[nested] [flat]

* [PATCH v4 3/3] Fix timeline-tracking failure while sending a historic timeline
@ 2020-12-09 08:22  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Kyotaro Horiguchi @ 2020-12-09 08:22 UTC (permalink / raw)

Walsender should track timeline switches while sending a historic
timeline. Regain that behavior, which was broken in PG13, by a thinko
of 709d003fbd.
---
 src/backend/replication/walsender.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index fe0d368a35..8545c6c423 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -2491,7 +2491,7 @@ WalSndSegmentOpen(XLogReaderState *state, XLogSegNo nextSegNo,
 		XLogSegNo	endSegNo;
 
 		XLByteToSeg(sendTimeLineValidUpto, endSegNo, state->segcxt.ws_segsize);
-		if (state->seg.ws_segno == endSegNo)
+		if (nextSegNo == endSegNo)
 			*tli_p = sendTimeLineNextTLI;
 	}
 
-- 
2.27.0


----Next_Part(Thu_Jan__7_16_32_36_2021_122)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0001-Fix-timeline-tracking-failure-while-sending-a-PG13.patch.txt"



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

* [PATCH v3 3/7] Handle pg_get_viewdef default args in system_functions.sql
@ 2025-12-09 17:33  Mark Wong <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Mark Wong @ 2025-12-09 17:33 UTC (permalink / raw)

Modernize pg_get_viewdef to use CREATE OR REPLACE FUNCTION to handle the
optional pretty argument for both versions that use OID or view name.
---
 src/backend/catalog/system_functions.sql | 14 ++++++++
 src/backend/utils/adt/ruleutils.c        | 44 ------------------------
 src/include/catalog/pg_proc.dat          | 11 ++----
 src/include/catalog/pg_retired.dat       |  4 ++-
 4 files changed, 19 insertions(+), 54 deletions(-)

diff --git a/src/backend/catalog/system_functions.sql b/src/backend/catalog/system_functions.sql
index 3aad2fbf8f3..4ddbf194fa8 100644
--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -664,6 +664,20 @@ LANGUAGE INTERNAL
 PARALLEL SAFE
 AS 'pg_get_ruledef';
 
+CREATE OR REPLACE FUNCTION
+  pg_get_viewdef(view text, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL RESTRICTED
+AS 'pg_get_viewdef_name';
+
+CREATE OR REPLACE FUNCTION
+  pg_get_viewdef(view oid, pretty bool DEFAULT false)
+RETURNS TEXT
+LANGUAGE INTERNAL
+PARALLEL RESTRICTED
+AS 'pg_get_viewdef';
+
 --
 -- The default permissions for functions mean that anyone can execute them.
 -- A number of functions shouldn't be executable by just anyone, but rather
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 3733212fe0a..29557f3c9d2 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -658,25 +658,6 @@ pg_get_ruledef_worker(Oid ruleoid, int prettyFlags)
  */
 Datum
 pg_get_viewdef(PG_FUNCTION_ARGS)
-{
-	/* By OID */
-	Oid			viewoid = PG_GETARG_OID(0);
-	int			prettyFlags;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	res = pg_get_viewdef_worker(viewoid, prettyFlags, WRAP_COLUMN_DEFAULT);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-
-Datum
-pg_get_viewdef_ext(PG_FUNCTION_ARGS)
 {
 	/* By OID */
 	Oid			viewoid = PG_GETARG_OID(0);
@@ -716,31 +697,6 @@ pg_get_viewdef_wrap(PG_FUNCTION_ARGS)
 
 Datum
 pg_get_viewdef_name(PG_FUNCTION_ARGS)
-{
-	/* By qualified name */
-	text	   *viewname = PG_GETARG_TEXT_PP(0);
-	int			prettyFlags;
-	RangeVar   *viewrel;
-	Oid			viewoid;
-	char	   *res;
-
-	prettyFlags = PRETTYFLAG_INDENT;
-
-	/* Look up view name.  Can't lock it - we might not have privileges. */
-	viewrel = makeRangeVarFromNameList(textToQualifiedNameList(viewname));
-	viewoid = RangeVarGetRelid(viewrel, NoLock, false);
-
-	res = pg_get_viewdef_worker(viewoid, prettyFlags, WRAP_COLUMN_DEFAULT);
-
-	if (res == NULL)
-		PG_RETURN_NULL();
-
-	PG_RETURN_TEXT_P(string_to_text(res));
-}
-
-
-Datum
-pg_get_viewdef_name_ext(PG_FUNCTION_ARGS)
 {
 	/* By qualified name */
 	text	   *viewname = PG_GETARG_TEXT_PP(0);
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 2a3362567a7..531d0dea7db 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -3961,13 +3961,6 @@
   proargtypes => 'oid oid', prosrc => 'oidge' },
 
 # System-view support functions
-{ oid => '1640', descr => 'select statement of a view',
-  proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r',
-  prorettype => 'text', proargtypes => 'text',
-  prosrc => 'pg_get_viewdef_name' },
-{ oid => '1641', descr => 'select statement of a view',
-  proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r',
-  prorettype => 'text', proargtypes => 'oid', prosrc => 'pg_get_viewdef' },
 { oid => '1642', descr => 'role name by OID (with fallback)',
   proname => 'pg_get_userbyid', provolatile => 's', prorettype => 'name',
   proargtypes => 'oid', prosrc => 'pg_get_userbyid' },
@@ -8510,12 +8503,12 @@
   descr => 'select statement of a view with pretty-print option',
   proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r',
   prorettype => 'text', proargtypes => 'text bool',
-  prosrc => 'pg_get_viewdef_name_ext' },
+  prosrc => 'pg_get_viewdef_name' },
 { oid => '2506',
   descr => 'select statement of a view with pretty-print option',
   proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r',
   prorettype => 'text', proargtypes => 'oid bool',
-  prosrc => 'pg_get_viewdef_ext' },
+  prosrc => 'pg_get_viewdef' },
 { oid => '3159',
   descr => 'select statement of a view with pretty-printing and specified line wrapping',
   proname => 'pg_get_viewdef', provolatile => 's', proparallel => 'r',
diff --git a/src/include/catalog/pg_retired.dat b/src/include/catalog/pg_retired.dat
index a3ce10c7f62..d5d51ddb3e8 100644
--- a/src/include/catalog/pg_retired.dat
+++ b/src/include/catalog/pg_retired.dat
@@ -17,6 +17,8 @@
 # At the same time, it may be good to be reminded what procedure was associated
 # with it.
 
-{ oid => '1573', proname => 'pg_get_ruledef' }
+{ oid => '1573', proname => 'pg_get_ruledef' },
+{ oid => '1640', proname => 'pg_get_viewdef' },
+{ oid => '1641', proname => 'pg_get_viewdef' }
 
 ]
-- 
2.43.0


--zd8Z8rlPOcTi77n/
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
	filename="v3-0004-Handle-pg_get_indexdef-default-args-in-system_fun.patch"



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


end of thread, other threads:[~2025-12-09 17:33 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 08:22 [PATCH v4 3/3] Fix timeline-tracking failure while sending a historic timeline Kyotaro Horiguchi <[email protected]>
2025-12-09 17:33 [PATCH v3 3/7] Handle pg_get_viewdef default args in system_functions.sql Mark Wong <[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