You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix the invalid oidAssignments list for CTAS query with initplan (#12472)
If a query is a CTAS with initplan, it may reset 'Oid dispatch context'
when an exception occurs in preprocess_initplans, which will further
cause invlid list reference during the serialization of oidAssignments
when dispatching plan.
In this fix, we copy an extra list for oidAssignments for querys
that contain CTAS and initplan.
Co-authored-by: wuchengwen <wcw190496@alibaba-inc.com>
Copy file name to clipboardExpand all lines: src/test/regress/expected/gpctas.out
+30-6Lines changed: 30 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -146,17 +146,16 @@ ALTER TABLE ctas_src DROP COLUMN col2;
146
146
INSERT INTO ctas_src(col1, col3,col4,col5)
147
147
SELECT g, 'a',True,g from generate_series(1,5) g;
148
148
CREATE TABLE ctas_dst as SELECT col1,col3,col4,col5 FROM ctas_src order by 1;
149
-
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col4' as the Greenplum Database data distribution key for this table.
150
-
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
149
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause. Creating a NULL policy entry.
151
150
-- This will fail to find some of the rows, if they're distributed incorrectly.
152
151
SELECT * FROM ctas_src, ctas_dst WHERE ctas_src.col1 = ctas_dst.col1;
@@ -203,8 +202,7 @@ CREATE TABLE ctas_base(a int, b int);
203
202
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
204
203
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
205
204
CREATE TABLE ctas_aocs WITH (appendonly=true, orientation=column) AS SELECT * FROM ctas_base WITH NO DATA;
206
-
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'a' as the Greenplum Database data distribution key for this table.
207
-
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
205
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause. Creating a NULL policy entry.
208
206
SELECT * FROM ctas_aocs;
209
207
a | b
210
208
---+---
@@ -303,3 +301,29 @@ from
303
301
refresh materialized view sro_mv_issue_11999;
304
302
ERROR: division by zero
305
303
CONTEXT: SQL function "mv_action_select_issue_11999" statement 1
304
+
-- Test CTAS + initplan, and an exception was raised in preprocess_initplans
305
+
CREATE OR REPLACE FUNCTION public.exception_func()
306
+
RETURNS refcursor
307
+
LANGUAGE plpgsql
308
+
AS $function$declare cname refcursor = 'result'; begin open cname for select 1; raise sqlstate '02000'; return cname; exception when sqlstate '02000' then return cname; end;$function$;
309
+
SELECT exception_func() INTO TEMPORARY test_tmp1;
310
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named '' as the Greenplum Database data distribution key for this table.
311
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
312
+
SELECT * FROM test_tmp1;
313
+
exception_func
314
+
----------------
315
+
result
316
+
(1 row)
317
+
318
+
CREATE TEMPORARY TABLE test_tmp2 AS SELECT exception_func();
319
+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named '' as the Greenplum Database data distribution key for this table.
320
+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
Copy file name to clipboardExpand all lines: src/test/regress/sql/gpctas.sql
+19Lines changed: 19 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -199,3 +199,22 @@ from
199
199
200
200
-- then refresh should error out
201
201
refresh materialized view sro_mv_issue_11999;
202
+
203
+
204
+
-- Test CTAS + initplan, and an exception was raised in preprocess_initplans
205
+
CREATE OR REPLACEFUNCTIONpublic.exception_func()
206
+
RETURNS refcursor
207
+
LANGUAGE plpgsql
208
+
AS $function$declare cname refcursor ='result'; begin open cname for select1; raise sqlstate '02000'; return cname; exception when sqlstate '02000' then return cname; end;$function$;
0 commit comments