From 0d6450de273eaafeec8677d4e6679cad5e0f3b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=B2=B2=E9=B9=8F?= Date: Sat, 17 Oct 2020 10:25:47 +0800 Subject: [PATCH 1/4] =?UTF-8?q?update=20src/gausskernel/optimizer/plan/cre?= =?UTF-8?q?ateplan.cpp.=20=E4=BF=AE=E6=94=B9create=5Fappend=5Fplan?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=AD=E5=AF=B9=20path=E4=B8=BAsubquery?= =?UTF-8?q?=E4=B8=94bestpath->subpaths=E4=B8=BA=E7=A9=BA=20=E7=9A=84?= =?UTF-8?q?=E6=83=85=E5=86=B5=E7=9A=84=E5=A4=84=E7=90=86=20=E5=8F=82?= =?UTF-8?q?=E8=80=83Gaussdb=E5=92=8CPostgres=E4=B8=AD=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=EF=BC=8C=E5=B0=86=E5=8E=9F=E6=9C=89=E7=9A=84?= =?UTF-8?q?=E6=96=AD=E8=A8=80=E4=BF=AE=E6=94=B9=E4=B8=BAif=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E3=80=82=20=E5=BD=93=E5=87=BA=E7=8E=B0=E4=B8=8A?= =?UTF-8?q?=E8=BF=B0=E6=83=85=E5=86=B5=E6=98=AF=E5=88=A4=E6=96=ADsubplan?= =?UTF-8?q?=E4=B8=BAdummy=20plan=EF=BC=8C=E6=98=AF=E5=88=99=E7=BB=A7?= =?UTF-8?q?=E7=BB=AD=E6=89=A7=E8=A1=8Cmake=5Fsubqueryscan;=E5=8F=8D?= =?UTF-8?q?=E4=B9=8B=E5=88=99=E6=89=A7=E8=A1=8Cmake=5Fresult.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/optimizer/plan/createplan.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gausskernel/optimizer/plan/createplan.cpp b/src/gausskernel/optimizer/plan/createplan.cpp index 6c7476aa6..890916aa9 100644 --- a/src/gausskernel/optimizer/plan/createplan.cpp +++ b/src/gausskernel/optimizer/plan/createplan.cpp @@ -1072,8 +1072,8 @@ static Plan* create_append_plan(PlannerInfo* root, AppendPath* best_path) * subquery's rangetable so that the executor will apply permissions * checks to those rels at runtime.) */ - if (rel->rtekind == RTE_SUBQUERY) { - Assert(is_dummy_plan(rel->subplan)); + if (rel->rtekind == RTE_SUBQUERY && + (rel->subplan != NULL && is_dummy_plan(rel->subplan) == true)) { return (Plan*)make_subqueryscan(tlist, NIL, rel->relid, rel->subplan); } else { /* Generate a Result plan with constant-FALSE gating qual */ From 35b648b91c1c66e487294c63a388cdf0a54f916d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=B2=B2=E9=B9=8F?= Date: Sat, 17 Oct 2020 10:28:04 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0sqlsmith=E4=BA=A7?= =?UTF-8?q?=E7=94=9F=E7=9A=84=E9=9A=8F=E6=9C=BAsql=E8=AF=AD=E5=8F=A5=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95create=5Fappend=5Fplan=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E7=9A=84=E4=BF=AE=E6=94=B9=E5=90=8E=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/regress/sql/test_sqlsmith.sql | 103 +++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 src/test/regress/sql/test_sqlsmith.sql diff --git a/src/test/regress/sql/test_sqlsmith.sql b/src/test/regress/sql/test_sqlsmith.sql new file mode 100644 index 000000000..4346bf4c7 --- /dev/null +++ b/src/test/regress/sql/test_sqlsmith.sql @@ -0,0 +1,103 @@ +select + pg_catalog.sysdate() as c0, + pg_catalog.sysdate() as c1 + from + pg_catalog.gs_wlm_ec_operator_info as sample_0 + left join (select + case when (select pg_catalog.max(start_date) from pg_catalog.pg_job) + = (select start_date from pg_catalog.pg_job limit 1 ) + then ref_0.nodename else ref_0.nodename end + as c0 + from + pg_catalog.gs_total_memory_detail as ref_0 + where false + limit 121) as subq_0 + on (pg_catalog.polygon( + cast(cast(null as circle) as circle)) |>> case when sample_0.average_peak_memory > cast(null as int8) then cast(null as polygon) else cast(null as polygon) end + ) + where true; + +select pg_catalog.max( + cast(cast(null as "date") as "date")) over (partition by ref_0.catchup_start order by ref_0.peer_role) as c0, + pg_catalog.inet_server_port() as c1, + ref_0.peer_role as c2, + ref_0.lwpid as c3, + pg_catalog.timeofday() as c4, + ref_0.catchup_end as c5, + case when true then ref_0.catchup_end else ref_0.catchup_end end + as c6, + ref_0.catchup_start as c7 + from + pg_catalog.pg_get_senders_catchup_time as ref_0 + where cast(coalesce(pg_catalog.int4_bpchar( + cast(ref_0.lwpid as int4)), + pg_catalog.int1_bpchar( + cast((select pg_catalog.bit_and(attcmprmode) from pg_catalog.pg_attribute) + as int1))) as bpchar) < case when case when ref_0.catchup_end >= case when cast(null as circle) <> cast(null as circle) then cast(null as "date") else cast(null as "date") end + then case when EXISTS ( + select + ref_1.ftoptions as c0, + ref_1.xc_node_id as c1, + ref_0.type as c2, + ref_0.catchup_end as c3, + ref_0.pid as c4, + ref_1.ftwriteonly as c5, + ref_0.catchup_start as c6, + ref_0.catchup_start as c7, + ref_0.pid as c8, + ref_1.xc_node_id as c9, + ref_1.ftserver as c10, + 61 as c11 + from + pg_catalog.pg_foreign_table as ref_1 + where cast(null as polygon) >> cast(null as polygon)) then cast(null as raw) else cast(null as raw) end + else case when EXISTS ( + select ref_1.ftoptions as c0, + ref_1.xc_node_id as c1, + ref_0.type as c2, + ref_0.catchup_end as c3, + ref_0.pid as c4, + ref_1.ftwriteonly as c5, + ref_0.catchup_start as c6, + ref_0.catchup_start as c7, + ref_0.pid as c8, + ref_1.xc_node_id as c9, + ref_1.ftserver as c10, + 61 as c11 + from + pg_catalog.pg_foreign_table as ref_1 + where cast(null as polygon) >> cast(null as polygon)) then cast(null as raw) else cast(null as raw) end + end + = cast(null as raw) then cast(null as bpchar) else cast(null as bpchar) end + limit 77; + +select + sample_0.adnum as c0, + (select starelid from pg_catalog.pg_statistic limit 1 offset 2) as c1, + subq_0.c0 as c2, + sample_0.adnum as c3, + subq_0.c0 as c4, + sample_0.adrelid as c5 +from + pg_catalog.pg_attrdef as sample_0 tablesample system (7.1) + left join + (select + (select schemaname from pg_catalog.pg_stat_xact_sys_tables limit 1 offset 3) as c0, + ref_0.catalog_name as c1 + from + information_schema.information_schema_catalog_name as ref_0 + where + (cast(null as circle) ~ cast(null as point)) + or + ( + (select group_buckets from pg_catalog.pgxc_group limit 1 offset 3) + ~>~ + (select pg_catalog.listagg(null_frac) from pg_catalog.pg_stats) + ) + ) as subq_0 +on (case when true then cast(null as circle) + else cast(null as circle) end + <> cast(coalesce(cast(null as circle), + cast(null as circle)) as circle)) +where + pg_catalog.now() <= pg_catalog.pg_systimestamp() \ No newline at end of file From 3fef364224f2f2074ad5a0097657039581b514aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=B2=B2=E9=B9=8F?= Date: Sat, 17 Oct 2020 10:28:45 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0test=5Fsqlsmith=E7=9A=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/regress/expected/test_sqlsmith.out | 115 ++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 src/test/regress/expected/test_sqlsmith.out diff --git a/src/test/regress/expected/test_sqlsmith.out b/src/test/regress/expected/test_sqlsmith.out new file mode 100644 index 000000000..3c8468602 --- /dev/null +++ b/src/test/regress/expected/test_sqlsmith.out @@ -0,0 +1,115 @@ +select + pg_catalog.sysdate() as c0, + pg_catalog.sysdate() as c1 + from + pg_catalog.gs_wlm_ec_operator_info as sample_0 + left join (select + case when (select pg_catalog.max(start_date) from pg_catalog.pg_job) + = (select start_date from pg_catalog.pg_job limit 1 ) + then ref_0.nodename else ref_0.nodename end + as c0 + from + pg_catalog.gs_total_memory_detail as ref_0 + where false + limit 121) as subq_0 + on (pg_catalog.polygon( + cast(cast(null as circle) as circle)) |>> case when sample_0.average_peak_memory > cast(null as int8) then cast(null as polygon) else cast(null as polygon) end + ) + where true; + c0 | c1 +----+---- +(0 rows) + + +select pg_catalog.max( + cast(cast(null as "date") as "date")) over (partition by ref_0.catchup_start order by ref_0.peer_role) as c0, + pg_catalog.inet_server_port() as c1, + ref_0.peer_role as c2, + ref_0.lwpid as c3, + pg_catalog.timeofday() as c4, + ref_0.catchup_end as c5, + case when true then ref_0.catchup_end else ref_0.catchup_end end + as c6, + ref_0.catchup_start as c7 + from + pg_catalog.pg_get_senders_catchup_time as ref_0 + where cast(coalesce(pg_catalog.int4_bpchar( + cast(ref_0.lwpid as int4)), + pg_catalog.int1_bpchar( + cast((select pg_catalog.bit_and(attcmprmode) from pg_catalog.pg_attribute) + as int1))) as bpchar) < case when case when ref_0.catchup_end >= case when cast(null as circle) <> cast(null as circle) then cast(null as "date") else cast(null as "date") end + then case when EXISTS ( + select + ref_1.ftoptions as c0, + ref_1.xc_node_id as c1, + ref_0.type as c2, + ref_0.catchup_end as c3, + ref_0.pid as c4, + ref_1.ftwriteonly as c5, + ref_0.catchup_start as c6, + ref_0.catchup_start as c7, + ref_0.pid as c8, + ref_1.xc_node_id as c9, + ref_1.ftserver as c10, + 61 as c11 + from + pg_catalog.pg_foreign_table as ref_1 + where cast(null as polygon) >> cast(null as polygon)) then cast(null as raw) else cast(null as raw) end + else case when EXISTS ( + select ref_1.ftoptions as c0, + ref_1.xc_node_id as c1, + ref_0.type as c2, + ref_0.catchup_end as c3, + ref_0.pid as c4, + ref_1.ftwriteonly as c5, + ref_0.catchup_start as c6, + ref_0.catchup_start as c7, + ref_0.pid as c8, + ref_1.xc_node_id as c9, + ref_1.ftserver as c10, + 61 as c11 + from + pg_catalog.pg_foreign_table as ref_1 + where cast(null as polygon) >> cast(null as polygon)) then cast(null as raw) else cast(null as raw) end + end + = cast(null as raw) then cast(null as bpchar) else cast(null as bpchar) end + limit 77; + c0 | c1 | c2 | c3 | c4 | c5 | c6 | c7 +----+----+----+----+----+----+----+---- +(0 rows) + + +select + sample_0.adnum as c0, + (select starelid from pg_catalog.pg_statistic limit 1 offset 2) as c1, + subq_0.c0 as c2, + sample_0.adnum as c3, + subq_0.c0 as c4, + sample_0.adrelid as c5 +from + pg_catalog.pg_attrdef as sample_0 tablesample system (7.1) + left join + (select + (select schemaname from pg_catalog.pg_stat_xact_sys_tables limit 1 offset 3) as c0, + ref_0.catalog_name as c1 + from + information_schema.information_schema_catalog_name as ref_0 + where + (cast(null as circle) ~ cast(null as point)) + or + ( + (select group_buckets from pg_catalog.pgxc_group limit 1 offset 3) + ~>~ + (select pg_catalog.listagg(null_frac) from pg_catalog.pg_stats) + ) + ) as subq_0 +on (case when true then cast(null as circle) + else cast(null as circle) end + <> cast(coalesce(cast(null as circle), + cast(null as circle)) as circle)) +where + pg_catalog.now() <= pg_catalog.pg_systimestamp() + c0 | c1 | c2 | c3 | c4 | c5 +----+----+----+----+----+---- +(0 rows) + From 7b3a11cb1a4890394b13401494094e516ce45f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=B2=B2=E9=B9=8F?= Date: Sat, 17 Oct 2020 11:33:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0sqlsmith=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=A0=B7=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/regress/parallel_schedule | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule index a5083e127..8989683f4 100644 --- a/src/test/regress/parallel_schedule +++ b/src/test/regress/parallel_schedule @@ -1,3 +1,5 @@ +# test random SQL statements generated by sqlsmith +test: test_sqlsmith test: partiton_pathkey_col_plan partiton_pathkey_col_randomexec partiton_pathkey_row_plan partiton_pathkey_row_randomexec #test the locales setting expect not affacted each other test: pg_session_locale