From 113163f4bb27aaace29354b284a616ff8c90f1db Mon Sep 17 00:00:00 2001 From: chenzhikai <895543892@qq.com> Date: Wed, 29 Mar 2023 09:07:49 +0800 Subject: [PATCH] =?UTF-8?q?dblink=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E5=AE=89=E5=85=A8=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/dblink/dblink.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contrib/dblink/dblink.cpp b/contrib/dblink/dblink.cpp index d93dc511b7..56916f7f61 100644 --- a/contrib/dblink/dblink.cpp +++ b/contrib/dblink/dblink.cpp @@ -157,8 +157,8 @@ static bool UseODBCLinker(char* connstr); PQLinker* plinker = New(SESS_GET_MEM_CXT_GROUP \ (MEMORY_CONTEXT_COMMUNICATION)) PQLinker(connstr); \ linker = plinker; \ - freeconn = true; \ } \ + freeconn = true; \ } \ } while (0) @@ -1207,7 +1207,7 @@ static Datum dblink_record_internal(FunctionCallInfo fcinfo, bool is_async) PG_CATCH(); { /* if needed, close the connection to the database */ - if (freeconn) { + if (freeconn && linker) { linker->finish(); } @@ -1216,7 +1216,7 @@ static Datum dblink_record_internal(FunctionCallInfo fcinfo, bool is_async) PG_END_TRY(); /* if needed, close the connection to the database */ - if (freeconn) { + if (freeconn && linker) { linker->finish(); } @@ -1674,7 +1674,7 @@ Datum dblink_exec(PG_FUNCTION_ARGS) PG_CATCH(); { /* if needed, close the connection to the database */ - if (freeconn) { + if (freeconn && linker) { linker->finish(); } PG_RE_THROW(); @@ -1682,7 +1682,7 @@ Datum dblink_exec(PG_FUNCTION_ARGS) PG_END_TRY(); /* if needed, close the connection to the database */ - if (freeconn) { + if (freeconn && linker) { linker->finish(); } -- Gitee