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 99a4ee79b91 Fix errors in analyze
99a4ee79b91 is described below
commit 99a4ee79b91ef360e67a3cd81ff62b9196b280ca
Author: Jinbao Chen <[email protected]>
AuthorDate: Mon Nov 10 22:33:34 2025 +0800
Fix errors in analyze
---
src/backend/commands/analyze.c | 1 +
src/test/regress/expected/inherit.out | 312 ++++++++++++++++++----------------
src/test/regress/expected/select.out | 6 -
3 files changed, 169 insertions(+), 150 deletions(-)
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index ddf9d4d3f34..cb436576d83 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -935,6 +935,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params,
*/
if (onerel->rd_rel->relkind == RELKIND_RELATION
&& onerel->rd_rel->relispartition)
{
+ MemoryContext old_context;
Datum *hll_values;
old_context =
MemoryContextSwitchTo(stats->anl_context);
diff --git a/src/test/regress/expected/inherit.out
b/src/test/regress/expected/inherit.out
index b09b6e35aa0..c7ab47c3138 100644
--- a/src/test/regress/expected/inherit.out
+++ b/src/test/regress/expected/inherit.out
@@ -550,6 +550,7 @@ $$begin raise notice 'updating some_tab'; return NULL;
end;$$
language plpgsql;
create trigger some_tab_stmt_trig
before update on some_tab execute function some_tab_stmt_trig_func();
+ERROR: Triggers for statements are not yet supported
explain (costs off)
update some_tab set f3 = 11 where f1 = 12 and f2 = 13;
QUERY PLAN
@@ -559,10 +560,10 @@ update some_tab set f3 = 11 where f1 = 12 and f2 = 13;
-> Result
-> Index Scan using some_tab_child_f1_f2_idx on some_tab_child
some_tab_1
Index Cond: ((f1 = 12) AND (f2 = 13))
-(5 rows)
+ Optimizer: Postgres query optimizer
+(6 rows)
update some_tab set f3 = 11 where f1 = 12 and f2 = 13;
-NOTICE: updating some_tab
drop table some_tab cascade;
NOTICE: drop cascades to table some_tab_child
drop function some_tab_stmt_trig_func();
@@ -1660,27 +1661,29 @@ select min(1-id) from matest0;
reset enable_seqscan;
reset enable_parallel_append;
-<<<<<<< HEAD
reset enable_bitmapscan;
-=======
explain (verbose, costs off) -- bug #18652
select 1 - id as c from
(select id from matest3 t1 union all select id * 2 from matest3 t2) ss
order by c;
- QUERY PLAN
-------------------------------------------------------------
- Result
+ QUERY PLAN
+------------------------------------------------------------------
+ Gather Motion 3:1 (slice1; segments: 3)
Output: ((1 - t1.id))
- -> Merge Append
- Sort Key: ((1 - t1.id))
- -> Index Scan using matest3i on public.matest3 t1
- Output: t1.id, (1 - t1.id)
- -> Sort
- Output: ((t2.id * 2)), ((1 - (t2.id * 2)))
- Sort Key: ((1 - (t2.id * 2)))
- -> Seq Scan on public.matest3 t2
- Output: (t2.id * 2), (1 - (t2.id * 2))
-(11 rows)
+ Merge Key: ((1 - t1.id))
+ -> Result
+ Output: ((1 - t1.id))
+ -> Merge Append
+ Sort Key: ((1 - t1.id))
+ -> Index Scan using matest3i on public.matest3 t1
+ Output: t1.id, (1 - t1.id)
+ -> Sort
+ Output: ((t2.id * 2)), ((1 - (t2.id * 2)))
+ Sort Key: ((1 - (t2.id * 2)))
+ -> Seq Scan on public.matest3 t2
+ Output: (t2.id * 2), (1 - (t2.id * 2))
+ Optimizer: Postgres query optimizer
+(15 rows)
select 1 - id as c from
(select id from matest3 t1 union all select id * 2 from matest3 t2) ss
@@ -1693,7 +1696,6 @@ order by c;
-4
(4 rows)
->>>>>>> REL_16_9
drop table matest0 cascade;
NOTICE: drop cascades to 3 other objects
DETAIL: drop cascades to table matest1
@@ -1926,39 +1928,22 @@ insert into inhpar select x, x::text from
generate_series(1,5) x;
insert into inhcld select x::text, x from generate_series(6,10) x;
explain (verbose, costs off)
update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit
1);
- QUERY PLAN
--------------------------------------------------------------------------
- Update on public.inhpar i
- Update on public.inhpar i_1
- Update on public.inhcld i_2
- -> Result
- Output: $2, $3, (SubPlan 1 (returns $2,$3)), i.tableoid, i.ctid
- -> Append
- -> Seq Scan on public.inhpar i_1
- Output: i_1.f1, i_1.f2, i_1.tableoid, i_1.ctid
- -> Seq Scan on public.inhcld i_2
- Output: i_2.f1, i_2.f2, i_2.tableoid, i_2.ctid
- SubPlan 1 (returns $2,$3)
- -> Limit
- Output: (i.f1), (((i.f2)::text || '-'::text))
- -> Seq Scan on public.int4_tbl
- Output: i.f1, ((i.f2)::text || '-'::text)
-(15 rows)
-
+ERROR: can't split update for inherit table: inhpar (preptlist.c:139)
update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit
1);
+ERROR: can't split update for inherit table: inhpar (preptlist.c:139)
select * from inhpar;
- f1 | f2
-----+-----
- 1 | 1-
- 2 | 2-
- 3 | 3-
- 4 | 4-
- 5 | 5-
- 6 | 6-
- 7 | 7-
- 8 | 8-
- 9 | 9-
- 10 | 10-
+ f1 | f2
+----+----
+ 2 | 2
+ 3 | 3
+ 4 | 4
+ 9 | 9
+ 10 | 10
+ 1 | 1
+ 7 | 7
+ 5 | 5
+ 6 | 6
+ 8 | 8
(10 rows)
drop table inhpar cascade;
@@ -1974,22 +1959,39 @@ alter table inhpar attach partition inhcld2 for values
from (5) to (100);
insert into inhpar select x, x::text from generate_series(1,10) x;
explain (verbose, costs off)
update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit
1);
- QUERY PLAN
------------------------------------------------------------------------------------
+ QUERY PLAN
+----------------------------------------------------------------------------------------------------------------------------------
Update on public.inhpar i
Update on public.inhcld1 i_1
Update on public.inhcld2 i_2
- -> Append
- -> Seq Scan on public.inhcld1 i_1
- Output: $2, $3, (SubPlan 1 (returns $2,$3)), i_1.tableoid,
i_1.ctid
- SubPlan 1 (returns $2,$3)
- -> Limit
- Output: (i_1.f1), (((i_1.f2)::text || '-'::text))
- -> Seq Scan on public.int4_tbl
- Output: i_1.f1, ((i_1.f2)::text || '-'::text)
- -> Seq Scan on public.inhcld2 i_2
- Output: $2, $3, (SubPlan 1 (returns $2,$3)), i_2.tableoid,
i_2.ctid
-(13 rows)
+ -> Explicit Redistribute Motion 3:3 (slice1; segments: 3)
+ Output: ($2), (($3)::name), ((SubPlan 1 (returns $2,$3) (copy 2))),
i.tableoid, i.ctid, i.gp_segment_id, (DMLAction)
+ -> Split
+ Output: ($2), (($3)::name), ((SubPlan 1 (returns $2,$3) (copy
2))), i.tableoid, i.ctid, i.gp_segment_id, DMLAction
+ -> Append
+ -> Seq Scan on public.inhcld1 i_1
+ Output: $2, $3, (SubPlan 1 (returns $2,$3) (copy
2)), i_1.tableoid, i_1.ctid, i_1.gp_segment_id
+ SubPlan 1 (returns $2,$3) (copy 2)
+ -> Limit
+ Output: (i_1.f1), (((i_1.f2)::text ||
'-'::text))
+ -> Result
+ Output: i_1.f1, ((i_1.f2)::text ||
'-'::text)
+ -> Materialize
+ -> Broadcast Motion 3:3
(slice2; segments: 3)
+ -> Seq Scan on
public.int4_tbl
+ -> Seq Scan on public.inhcld2 i_2
+ Output: $2, $3, (SubPlan 1 (returns $2,$3) (copy
3)), i_2.tableoid, i_2.ctid, i_2.gp_segment_id
+ SubPlan 1 (returns $2,$3) (copy 3)
+ -> Limit
+ Output: (i_2.f1), (((i_2.f2)::text ||
'-'::text))
+ -> Result
+ Output: i_2.f1, ((i_2.f2)::text ||
'-'::text)
+ -> Materialize
+ -> Broadcast Motion 3:3
(slice3; segments: 3)
+ -> Seq Scan on
public.int4_tbl int4_tbl_1
+ Settings: enable_mergejoin = 'on', enable_bitmapscan = 'off',
enable_indexscan = 'on', enable_seqscan = 'off'
+ Optimizer: Postgres query optimizer
+(30 rows)
update inhpar i set (f1, f2) = (select i.f1, i.f2 || '-' from int4_tbl limit
1);
select * from inhpar;
@@ -2010,16 +2012,17 @@ select * from inhpar;
-- Also check ON CONFLICT
insert into inhpar as i values (3), (7) on conflict (f1)
do update set (f1, f2) = (select i.f1, i.f2 || '+');
+ERROR: modification of distribution columns in OnConflictUpdate is not
supported
select * from inhpar order by f1; -- tuple order might be unstable here
f1 | f2
----+-----
1 | 1-
2 | 2-
- 3 | 3-+
+ 3 | 3-
4 | 4-
5 | 5-
6 | 6-
- 7 | 7-+
+ 7 | 7-
8 | 8-
9 | 9-
10 | 10-
@@ -2595,109 +2598,130 @@ explain (costs off) select * from mclparted order by
a;
(9 rows)
explain (costs off) select * from mclparted where a in(3,4,5) order by a;
- QUERY PLAN
-----------------------------------------------------------------------------
- Merge Append
- Sort Key: mclparted.a
- -> Index Only Scan using mclparted3_5_a_idx on mclparted3_5 mclparted_1
- Index Cond: (a = ANY ('{3,4,5}'::integer[]))
- -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_2
- Index Cond: (a = ANY ('{3,4,5}'::integer[]))
-(6 rows)
+ QUERY PLAN
+----------------------------------------------------------------------------------
+ Gather Motion 2:1 (slice1; segments: 2)
+ Merge Key: mclparted.a
+ -> Merge Append
+ Sort Key: mclparted.a
+ -> Index Only Scan using mclparted3_5_a_idx on mclparted3_5
mclparted_1
+ Index Cond: (a = ANY ('{3,4,5}'::integer[]))
+ -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_2
+ Index Cond: (a = ANY ('{3,4,5}'::integer[]))
+ Optimizer: Postgres query optimizer
+(9 rows)
-- Introduce a NULL and DEFAULT partition so we can test more complex cases
create table mclparted_null partition of mclparted for values in(null);
create table mclparted_def partition of mclparted default;
-- Append can be used providing we don't scan the interleaved partition
explain (costs off) select * from mclparted where a in(1,2,4) order by a;
- QUERY PLAN
-------------------------------------------------------------------------
- Append
- -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1
- Index Cond: (a = ANY ('{1,2,4}'::integer[]))
- -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2
- Index Cond: (a = ANY ('{1,2,4}'::integer[]))
- -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_3
- Index Cond: (a = ANY ('{1,2,4}'::integer[]))
-(7 rows)
+ QUERY PLAN
+------------------------------------------------------------------------------
+ Gather Motion 2:1 (slice1; segments: 2)
+ Merge Key: mclparted.a
+ -> Append
+ -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1
+ Index Cond: (a = ANY ('{1,2,4}'::integer[]))
+ -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2
+ Index Cond: (a = ANY ('{1,2,4}'::integer[]))
+ -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_3
+ Index Cond: (a = ANY ('{1,2,4}'::integer[]))
+ Optimizer: Postgres query optimizer
+(10 rows)
explain (costs off) select * from mclparted where a in(1,2,4) or a is null
order by a;
- QUERY PLAN
---------------------------------------------------------------------------------
- Append
- -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1
- Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
- -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2
- Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
- -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_3
- Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
- -> Index Only Scan using mclparted_null_a_idx on mclparted_null mclparted_4
- Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
-(9 rows)
+ QUERY PLAN
+--------------------------------------------------------------------------------------
+ Gather Motion 3:1 (slice1; segments: 3)
+ Merge Key: mclparted.a
+ -> Append
+ -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1
+ Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
+ -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2
+ Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
+ -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_3
+ Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
+ -> Index Only Scan using mclparted_null_a_idx on mclparted_null
mclparted_4
+ Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
+ Optimizer: Postgres query optimizer
+(12 rows)
-- Test a more complex case where the NULL partition allows some other value
drop table mclparted_null;
create table mclparted_0_null partition of mclparted for values in(0,null);
-- Ensure MergeAppend is used since 0 and NULLs are in the same partition.
explain (costs off) select * from mclparted where a in(1,2,4) or a is null
order by a;
- QUERY PLAN
-------------------------------------------------------------------------------------
- Merge Append
- Sort Key: mclparted.a
- -> Index Only Scan using mclparted_0_null_a_idx on mclparted_0_null
mclparted_1
- Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
- -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_2
- Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
- -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_3
- Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
- -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_4
- Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
-(10 rows)
+ QUERY PLAN
+------------------------------------------------------------------------------------------
+ Gather Motion 3:1 (slice1; segments: 3)
+ Merge Key: mclparted.a
+ -> Merge Append
+ Sort Key: mclparted.a
+ -> Index Only Scan using mclparted_0_null_a_idx on mclparted_0_null
mclparted_1
+ Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
+ -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_2
+ Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
+ -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_3
+ Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
+ -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_4
+ Filter: ((a = ANY ('{1,2,4}'::integer[])) OR (a IS NULL))
+ Optimizer: Postgres query optimizer
+(13 rows)
explain (costs off) select * from mclparted where a in(0,1,2,4) order by a;
- QUERY PLAN
-------------------------------------------------------------------------------------
- Merge Append
- Sort Key: mclparted.a
- -> Index Only Scan using mclparted_0_null_a_idx on mclparted_0_null
mclparted_1
- Index Cond: (a = ANY ('{0,1,2,4}'::integer[]))
- -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_2
- Index Cond: (a = ANY ('{0,1,2,4}'::integer[]))
- -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_3
- Index Cond: (a = ANY ('{0,1,2,4}'::integer[]))
- -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_4
- Index Cond: (a = ANY ('{0,1,2,4}'::integer[]))
-(10 rows)
+ QUERY PLAN
+------------------------------------------------------------------------------------------
+ Gather Motion 2:1 (slice1; segments: 2)
+ Merge Key: mclparted.a
+ -> Merge Append
+ Sort Key: mclparted.a
+ -> Index Only Scan using mclparted_0_null_a_idx on mclparted_0_null
mclparted_1
+ Index Cond: (a = ANY ('{0,1,2,4}'::integer[]))
+ -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_2
+ Index Cond: (a = ANY ('{0,1,2,4}'::integer[]))
+ -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_3
+ Index Cond: (a = ANY ('{0,1,2,4}'::integer[]))
+ -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_4
+ Index Cond: (a = ANY ('{0,1,2,4}'::integer[]))
+ Optimizer: Postgres query optimizer
+(13 rows)
-- Ensure Append is used when the null partition is pruned
explain (costs off) select * from mclparted where a in(1,2,4) order by a;
- QUERY PLAN
-------------------------------------------------------------------------
- Append
- -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1
- Index Cond: (a = ANY ('{1,2,4}'::integer[]))
- -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2
- Index Cond: (a = ANY ('{1,2,4}'::integer[]))
- -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_3
- Index Cond: (a = ANY ('{1,2,4}'::integer[]))
-(7 rows)
-
--- Ensure MergeAppend is used when the default partition is not pruned
-explain (costs off) select * from mclparted where a in(1,2,4,100) order by a;
QUERY PLAN
------------------------------------------------------------------------------
- Merge Append
- Sort Key: mclparted.a
- -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1
- Index Cond: (a = ANY ('{1,2,4,100}'::integer[]))
- -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2
- Index Cond: (a = ANY ('{1,2,4,100}'::integer[]))
- -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_3
- Index Cond: (a = ANY ('{1,2,4,100}'::integer[]))
- -> Index Only Scan using mclparted_def_a_idx on mclparted_def mclparted_4
- Index Cond: (a = ANY ('{1,2,4,100}'::integer[]))
+ Gather Motion 2:1 (slice1; segments: 2)
+ Merge Key: mclparted.a
+ -> Append
+ -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1
+ Index Cond: (a = ANY ('{1,2,4}'::integer[]))
+ -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2
+ Index Cond: (a = ANY ('{1,2,4}'::integer[]))
+ -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_3
+ Index Cond: (a = ANY ('{1,2,4}'::integer[]))
+ Optimizer: Postgres query optimizer
(10 rows)
+-- Ensure MergeAppend is used when the default partition is not pruned
+explain (costs off) select * from mclparted where a in(1,2,4,100) order by a;
+ QUERY PLAN
+------------------------------------------------------------------------------------
+ Gather Motion 3:1 (slice1; segments: 3)
+ Merge Key: mclparted.a
+ -> Merge Append
+ Sort Key: mclparted.a
+ -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1
+ Index Cond: (a = ANY ('{1,2,4,100}'::integer[]))
+ -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2
+ Index Cond: (a = ANY ('{1,2,4,100}'::integer[]))
+ -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_3
+ Index Cond: (a = ANY ('{1,2,4,100}'::integer[]))
+ -> Index Only Scan using mclparted_def_a_idx on mclparted_def
mclparted_4
+ Index Cond: (a = ANY ('{1,2,4,100}'::integer[]))
+ Optimizer: Postgres query optimizer
+(13 rows)
+
drop table mclparted;
reset enable_sort;
reset enable_bitmapscan;
diff --git a/src/test/regress/expected/select.out
b/src/test/regress/expected/select.out
index 8fff6d5124e..7fb70339db7 100644
--- a/src/test/regress/expected/select.out
+++ b/src/test/regress/expected/select.out
@@ -292,13 +292,7 @@ SELECT onek2.unique1, onek2.stringu1 FROM onek2
RESET enable_seqscan;
RESET enable_bitmapscan;
RESET enable_sort;
-<<<<<<< HEAD
RESET optimizer_enable_tablescan;
-SELECT two, stringu1, ten, string4
- INTO TABLE tmp
- FROM onek;
-=======
->>>>>>> REL_16_9
--
-- awk '{print $1,$2;}' person.data |
-- awk '{if(NF!=2){print $3,$2;}else{print;}}' - emp.data |
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]