You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by ch...@apache.org on 2025/11/03 02:03:23 UTC

(cloudberry) branch cbdb-postgres-merge updated: Do not call memory accouting functions in general context

This is an automated email from the ASF dual-hosted git repository.

chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/cbdb-postgres-merge by this push:
     new dec322fcf5f Do not call memory accouting functions in general context
dec322fcf5f is described below

commit dec322fcf5fb17828ad9e42654835f053b70d9e7
Author: Jinbao Chen <ch...@gmail.com>
AuthorDate: Mon Nov 3 10:03:08 2025 +0800

    Do not call memory accouting functions in general context
---
 src/backend/cdb/cdbgroupingpaths.c        | 24 ++++++++++++++++--------
 src/backend/optimizer/plan/planner.c      |  4 ++++
 src/backend/utils/mmgr/aset.c             |  7 +++++--
 src/test/regress/expected/timestamp.out   | 10 ----------
 src/test/regress/expected/timestamptz.out | 10 ----------
 src/test/regress/serial_schedule          | 24 ++++++++++++------------
 src/test/regress/sql/timestamp.sql        |  8 --------
 src/test/regress/sql/timestamptz.sql      |  8 --------
 8 files changed, 37 insertions(+), 58 deletions(-)

diff --git a/src/backend/cdb/cdbgroupingpaths.c b/src/backend/cdb/cdbgroupingpaths.c
index cafd6955dce..489fb13c588 100644
--- a/src/backend/cdb/cdbgroupingpaths.c
+++ b/src/backend/cdb/cdbgroupingpaths.c
@@ -510,14 +510,21 @@ cdb_create_multistage_grouping_paths(PlannerInfo *root,
 				 * removing the origin plan's aggfilter can work around
 				 * this problem. We'll look at it again later.
 				 */
-//				ListCell   *lc;
-//				foreach(lc, root->agginfos)
-//				{
-//					AggInfo    *agginfo = (AggInfo *) lfirst(lc);
-//					Aggref	   *aggref = agginfo->representative_aggref;
-//					if (aggref->aggdistinct != NIL)
-//						aggref->aggfilter = NULL;
-//				}
+				ListCell   *lc;
+				foreach(lc, root->agginfos)
+				{
+					AggInfo    *agginfo = (AggInfo *) lfirst(lc);
+					ListCell   *lc2;
+
+					foreach(lc2, agginfo->aggrefs)
+					{
+						Aggref	   *aggref = lfirst(lc2);
+
+						if (aggref->aggdistinct != NIL)
+							aggref->aggfilter = NULL;
+					}
+
+				}
 				add_multi_dqas_hash_agg_path(root,
 											 cheapest_path,
 											 &ctx,
@@ -1913,6 +1920,7 @@ get_common_group_tles(PathTarget *target,
 
 	if (rollups)
 	{
+		ListCell   *lc;
 		bool		first = true;
 
 		foreach(lc, rollups)
diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c
index 94631be52b3..310ffd2d75c 100644
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -8356,6 +8356,9 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
 			}
 			if (input_rel->partial_pathlist && grouped_rel->consider_parallel)
 			{
+				Path	   *path = linitial(input_rel->partial_pathlist);
+				double		dNumGroups;
+
 				path = cdb_prepare_path_for_hashed_agg(root,
 														path,
 														path->pathtarget,
@@ -8508,6 +8511,7 @@ add_paths_to_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
 
 		if (gp_eager_two_phase_agg)
 		{
+			ListCell *lc;
 			foreach(lc, grouped_rel->pathlist)
 			{
 				Path *path = (Path *) lfirst(lc);
diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c
index da9664ab6dc..11723363d30 100644
--- a/src/backend/utils/mmgr/aset.c
+++ b/src/backend/utils/mmgr/aset.c
@@ -1773,7 +1773,7 @@ AllocSetGetCurrentUsage(MemoryContext context)
 }
 
 static Size
-AllocSetGetPeakUsage_recurse(MemoryContext parent, MemoryContext context)
+ AllocSetGetPeakUsage_recurse(MemoryContext parent, MemoryContext context)
 {
 	MemoryContext child;
 	Size		total;
@@ -1788,7 +1788,10 @@ AllocSetGetPeakUsage_recurse(MemoryContext parent, MemoryContext context)
 		if (childset->accountingParent == (AllocSet) parent)
 			AllocSetGetPeakUsage_recurse(parent, child);
 		else
-			total += AllocSetGetPeakUsage(child);
+		{
+			if (child->methods->get_peak_usage)
+				total += child->methods->get_peak_usage(child);
+		}
 	}
 
 	return total;
diff --git a/src/test/regress/expected/timestamp.out b/src/test/regress/expected/timestamp.out
index 53070a49fed..b666fa66ef4 100644
--- a/src/test/regress/expected/timestamp.out
+++ b/src/test/regress/expected/timestamp.out
@@ -754,16 +754,6 @@ ERROR:  stride must be greater than zero
 -- disallow negative intervals
 SELECT date_bin('-2 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp '1970-01-01 00:00:00');
 ERROR:  stride must be greater than zero
-<<<<<<< HEAD
-=======
--- test overflow cases
-select date_bin('15 minutes'::interval, timestamp '294276-12-30', timestamp '4000-12-20 BC');
-ERROR:  interval out of range
-select date_bin('200000000 days'::interval, '2024-02-01'::timestamp, '2024-01-01'::timestamp);
-ERROR:  interval out of range
-select date_bin('365000 days'::interval, '4400-01-01 BC'::timestamp, '4000-01-01 BC'::timestamp);
-ERROR:  timestamp out of range
->>>>>>> REL_16_9
 -- Test casting within a BETWEEN qualifier
 SELECT d1 - timestamp without time zone '1997-01-02' AS diff
   FROM TIMESTAMP_TBL
diff --git a/src/test/regress/expected/timestamptz.out b/src/test/regress/expected/timestamptz.out
index 3c94081acb1..58f3bb8923f 100644
--- a/src/test/regress/expected/timestamptz.out
+++ b/src/test/regress/expected/timestamptz.out
@@ -798,16 +798,6 @@ ERROR:  stride must be greater than zero
 -- disallow negative intervals
 SELECT date_bin('-2 days'::interval, timestamp with time zone '1970-01-01 01:00:00+00' , timestamp with time zone '1970-01-01 00:00:00+00');
 ERROR:  stride must be greater than zero
-<<<<<<< HEAD
-=======
--- test overflow cases
-select date_bin('15 minutes'::interval, timestamptz '294276-12-30', timestamptz '4000-12-20 BC');
-ERROR:  interval out of range
-select date_bin('200000000 days'::interval, '2024-02-01'::timestamptz, '2024-01-01'::timestamptz);
-ERROR:  interval out of range
-select date_bin('365000 days'::interval, '4400-01-01 BC'::timestamptz, '4000-01-01 BC'::timestamptz);
-ERROR:  timestamp out of range
->>>>>>> REL_16_9
 -- Test casting within a BETWEEN qualifier
 SELECT d1 - timestamp with time zone '1997-01-02' AS diff
   FROM TIMESTAMPTZ_TBL
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index 67da347bd71..f43ddda03f7 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -36,19 +36,19 @@ test: circle
 test: date
 test: time
 test: timetz
-# test: timestamp
-# test: timestamptz
-# test: interval
-# test: inet
-# test: macaddr
-# test: macaddr8
-# test: tstypes
-# test: geometry
-# test: horology
-# test: regex
+test: timestamp
+test: timestamptz
+test: interval
+test: inet
+test: macaddr
+test: macaddr8
+test: tstypes
+test: geometry
+test: horology
+test: regex
 # test: oidjoins
-# test: type_sanity
-# test: opr_sanity
+test: type_sanity
+test: opr_sanity
 # test: misc_sanity
 # test: comments
 # test: expressions
diff --git a/src/test/regress/sql/timestamp.sql b/src/test/regress/sql/timestamp.sql
index e06a8ef8fa0..2d83d18ba55 100644
--- a/src/test/regress/sql/timestamp.sql
+++ b/src/test/regress/sql/timestamp.sql
@@ -281,14 +281,6 @@ SELECT date_bin('0 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp
 -- disallow negative intervals
 SELECT date_bin('-2 days'::interval, timestamp '1970-01-01 01:00:00' , timestamp '1970-01-01 00:00:00');
 
-<<<<<<< HEAD
-=======
--- test overflow cases
-select date_bin('15 minutes'::interval, timestamp '294276-12-30', timestamp '4000-12-20 BC');
-select date_bin('200000000 days'::interval, '2024-02-01'::timestamp, '2024-01-01'::timestamp);
-select date_bin('365000 days'::interval, '4400-01-01 BC'::timestamp, '4000-01-01 BC'::timestamp);
-
->>>>>>> REL_16_9
 -- Test casting within a BETWEEN qualifier
 SELECT d1 - timestamp without time zone '1997-01-02' AS diff
   FROM TIMESTAMP_TBL
diff --git a/src/test/regress/sql/timestamptz.sql b/src/test/regress/sql/timestamptz.sql
index 0d53a63b887..6d746c85611 100644
--- a/src/test/regress/sql/timestamptz.sql
+++ b/src/test/regress/sql/timestamptz.sql
@@ -256,14 +256,6 @@ SELECT date_bin('0 days'::interval, timestamp with time zone '1970-01-01 01:00:0
 -- disallow negative intervals
 SELECT date_bin('-2 days'::interval, timestamp with time zone '1970-01-01 01:00:00+00' , timestamp with time zone '1970-01-01 00:00:00+00');
 
-<<<<<<< HEAD
-=======
--- test overflow cases
-select date_bin('15 minutes'::interval, timestamptz '294276-12-30', timestamptz '4000-12-20 BC');
-select date_bin('200000000 days'::interval, '2024-02-01'::timestamptz, '2024-01-01'::timestamptz);
-select date_bin('365000 days'::interval, '4400-01-01 BC'::timestamptz, '4000-01-01 BC'::timestamptz);
-
->>>>>>> REL_16_9
 -- Test casting within a BETWEEN qualifier
 SELECT d1 - timestamp with time zone '1997-01-02' AS diff
   FROM TIMESTAMPTZ_TBL


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org