From 122681ca0c536b97b5c95168ea91d0b05eee424a Mon Sep 17 00:00:00 2001 From: shijuzheng1997 Date: Tue, 15 Apr 2025 09:15:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=82=E6=95=B0=E5=8C=96gu?= =?UTF-8?q?c=E5=8F=82=E6=95=B0=E6=9C=AA=E5=BC=80=E5=90=AF=E6=97=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=A7=86=E5=9B=BEcore=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/catalog/query_parameterization_views.cpp | 6 ++++++ src/test/regress/expected/auto_parameterization_views.out | 5 +++++ src/test/regress/sql/auto_parameterization_views.sql | 1 + 3 files changed, 12 insertions(+) diff --git a/src/common/backend/catalog/query_parameterization_views.cpp b/src/common/backend/catalog/query_parameterization_views.cpp index 5cc9627ebf..5ea203d406 100644 --- a/src/common/backend/catalog/query_parameterization_views.cpp +++ b/src/common/backend/catalog/query_parameterization_views.cpp @@ -69,6 +69,7 @@ ParamView* GetAllParamQueries(uint32* num) bool found = false; CachedPlanSource* psrc = NULL; ParamCachedPlan* entry = NULL; + ParamView* results = (ParamView*)palloc(sizeof(ParamView) * MAX_PARAMETERIZED_QUERY_STORED); int2vector* vec = NULL; hash_seq_init(&seq, u_sess->param_cxt.parameterized_queries); @@ -107,6 +108,11 @@ Datum query_parameterization_views(PG_FUNCTION_ARGS) TupleDesc tupDesc = NULL; MemoryContext oldContext = NULL; funcCtx = SRF_FIRSTCALL_INIT(); + + if (u_sess->param_cxt.parameterized_queries == NULL) { + SRF_RETURN_DONE(funcCtx); + } + oldContext = MemoryContextSwitchTo(funcCtx->multi_call_memory_ctx); tupDesc = CreateTemplateTupleDesc(Natts_parameterization_views, false, TableAmHeap); diff --git a/src/test/regress/expected/auto_parameterization_views.out b/src/test/regress/expected/auto_parameterization_views.out index a926ac80f8..a9501b8b5d 100644 --- a/src/test/regress/expected/auto_parameterization_views.out +++ b/src/test/regress/expected/auto_parameterization_views.out @@ -1,3 +1,8 @@ +SELECT * FROM query_parameterization_views(); + reloid | query_type | is_bypass | param_types | param_nums | parameterized_query +--------+------------+-----------+-------------+------------+--------------------- +(0 rows) + set enable_query_parameterization=on; CREATE TABLE test(c1 INT, c2 INT); INSERT INTO test(C1, C2) VALUES(1, 1); diff --git a/src/test/regress/sql/auto_parameterization_views.sql b/src/test/regress/sql/auto_parameterization_views.sql index 17d9244311..61e5d0b6af 100644 --- a/src/test/regress/sql/auto_parameterization_views.sql +++ b/src/test/regress/sql/auto_parameterization_views.sql @@ -1,3 +1,4 @@ +SELECT * FROM query_parameterization_views(); set enable_query_parameterization=on; CREATE TABLE test(c1 INT, c2 INT); -- Gitee