agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 09/13] Fix the resource owner to be used
19+ messages / 2 participants
[nested] [flat]

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH 09/13] Fix the resource owner to be used
@ 2017-02-22 00:12  Kyotaro Horiguchi <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Kyotaro Horiguchi @ 2017-02-22 00:12 UTC (permalink / raw)

Fixup of previous commit.
---
 src/backend/executor/execAsync.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/backend/executor/execAsync.c b/src/backend/executor/execAsync.c
index 588ba18..a8e5f80 100644
--- a/src/backend/executor/execAsync.c
+++ b/src/backend/executor/execAsync.c
@@ -20,7 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
-#include "utils/resowner_private.h"
+#include "utils/memutils.h"
 
 static bool ExecAsyncEventWait(EState *estate, long timeout);
 static bool ExecAsyncConfigureWait(EState *estate, PendingAsyncRequest *areq,
@@ -297,8 +297,6 @@ ExecAsyncEventWait(EState *estate, long timeout)
 
 	if (estate->es_wait_event_set == NULL)
 	{
-		ResourceOwner savedOwner;
-
 		/*
 		 * Allow for a few extra events without reinitializing.  It
 		 * doesn't seem worth the complexity of doing anything very
@@ -308,26 +306,14 @@ ExecAsyncEventWait(EState *estate, long timeout)
 		estate->es_allocated_fd_events = estate->es_total_fd_events + 16;
 
 		/*
-		 * The wait event set created here should be released in case of
-		 * error.
+		 * The wait event set created here should be live beyond ExecutorState
+		 * context but released in case of error.
 		 */
-		savedOwner = CurrentResourceOwner;
-		CurrentResourceOwner = TopTransactionResourceOwner;
-
-		PG_TRY();
-		{
-			estate->es_wait_event_set =
-				CreateWaitEventSet(estate->es_query_cxt,
-								   estate->es_allocated_fd_events + 1);
-		}
-		PG_CATCH();
-		{
-			CurrentResourceOwner = savedOwner;
-			PG_RE_THROW();
-		}
-		PG_END_TRY();
+		estate->es_wait_event_set =
+			CreateWaitEventSet(TopTransactionContext,
+							   TopTransactionResourceOwner,
+							   estate->es_allocated_fd_events + 1);
 
-		CurrentResourceOwner = savedOwner;
 		AddWaitEventToSet(estate->es_wait_event_set,
 						  WL_LATCH_SET, PGINVALID_SOCKET, MyLatch, NULL);
 		reinit = true;
-- 
2.9.2


----Next_Part(Wed_Feb_22_17_39_45_2017_090)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="0008-Allow-wait-event-set-to-be-registered-to-resource-ow.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread

* [PATCH v2 1/4] Add ternary reloption type
@ 2025-09-04 14:34  Nikolay Shaplov <[email protected]>
  0 siblings, 0 replies; 19+ messages in thread

From: Nikolay Shaplov @ 2025-09-04 14:34 UTC (permalink / raw)

There is a tendency for boolean reloptions in PostgreSQL code, one with "on"
and "off" values, to be replaced with options with "on", "off",
"[use_global_settings]" behaviour.

For `vacuum_index_cleanup" and gist's `buffering` reloption such behavior have
been implemented as enum-tyoe option.

For vacuum_truncate this behaviour have been umplemented by adding additional
`is_set` flag to `bytea` representation of the reloptions.

Both solutions looks like workaround hacks to implement option with three
available states.

This patch introduce "ternary" reloption type, that behave like bool option,
but also has an additional "unset" state. This state may be reachable only by
not setting or RESETting an option, like in `vacuum_truncate` option, or it
may have some text alias that allow user to explicitly set it, like "auto" in
`vacuum_index_cleanup` or gist's `buffering`

`vacuum_truncate`, `vacuum_index_cleanup` and gist's `buffering` reloptions are
reimplemented as ternary  reloptions without significant behaviour changes.

---

This patch is split into four parts, to help reviewer grasp the login behind
it. I guess it is better to commit it as a single commit

---

Part1: Add regression tests that would be tests for ternary reloptions in
future, but now it checks the behaviour of reloptions that would become
ternary. There behaviour should not change, so adding tests before changing
anything. These tests should pass before applying the patch, and after it.
---
 src/test/regress/expected/reloptions.out | 36 ++++++++++++++++++++++++
 src/test/regress/sql/reloptions.sql      | 21 ++++++++++++++
 2 files changed, 57 insertions(+)

diff --git a/src/test/regress/expected/reloptions.out b/src/test/regress/expected/reloptions.out
index 9de19b4e3f..1c99f79ab0 100644
--- a/src/test/regress/expected/reloptions.out
+++ b/src/test/regress/expected/reloptions.out
@@ -98,6 +98,42 @@ SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
  {fillfactor=13,autovacuum_enabled=false}
 (1 row)
 
+-- Tests for future (FIXME) ternary options
+-- behave as boolean option: accept unassigned name and truncated value
+DROP TABLE reloptions_test;
+CREATE TABLE reloptions_test(i INT) WITH (vacuum_truncate);
+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
+       reloptions       
+------------------------
+ {vacuum_truncate=true}
+(1 row)
+
+DROP TABLE reloptions_test;
+CREATE TABLE reloptions_test(i INT) WITH (vacuum_truncate=FaLS);
+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
+       reloptions       
+------------------------
+ {vacuum_truncate=fals}
+(1 row)
+
+-- preferred "true" alias is used when storing
+DROP TABLE reloptions_test;
+CREATE TABLE reloptions_test(i INT) WITH (vacuum_index_cleanup=on);
+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
+        reloptions         
+---------------------------
+ {vacuum_index_cleanup=on}
+(1 row)
+
+-- custom "third" value is available
+DROP TABLE reloptions_test;
+CREATE TABLE reloptions_test(i INT) WITH (vacuum_index_cleanup=auto);
+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
+         reloptions          
+-----------------------------
+ {vacuum_index_cleanup=auto}
+(1 row)
+
 -- Test vacuum_truncate option
 DROP TABLE reloptions_test;
 CREATE TEMP TABLE reloptions_test(i INT NOT NULL, j text)
diff --git a/src/test/regress/sql/reloptions.sql b/src/test/regress/sql/reloptions.sql
index 24fbe0b478..f5980dafcb 100644
--- a/src/test/regress/sql/reloptions.sql
+++ b/src/test/regress/sql/reloptions.sql
@@ -59,6 +59,27 @@ UPDATE pg_class
 ALTER TABLE reloptions_test RESET (illegal_option);
 SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
 
+-- Tests for future (FIXME) ternary options
+
+-- behave as boolean option: accept unassigned name and truncated value
+DROP TABLE reloptions_test;
+CREATE TABLE reloptions_test(i INT) WITH (vacuum_truncate);
+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
+
+DROP TABLE reloptions_test;
+CREATE TABLE reloptions_test(i INT) WITH (vacuum_truncate=FaLS);
+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
+
+-- preferred "true" alias is used when storing
+DROP TABLE reloptions_test;
+CREATE TABLE reloptions_test(i INT) WITH (vacuum_index_cleanup=on);
+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
+
+-- custom "third" value is available
+DROP TABLE reloptions_test;
+CREATE TABLE reloptions_test(i INT) WITH (vacuum_index_cleanup=auto);
+SELECT reloptions FROM pg_class WHERE oid = 'reloptions_test'::regclass;
+
 -- Test vacuum_truncate option
 DROP TABLE reloptions_test;
 
-- 
2.39.2


--nextPart5129932.5fSG56mABF
Content-Disposition: attachment;
 filename="v2-0002-Introduce-ternary-reloptions.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="unicode-2-0-utf-8";
 name="v2-0002-Introduce-ternary-reloptions.patch"



^ permalink  raw  reply  [nested|flat] 19+ messages in thread


end of thread, other threads:[~2025-09-04 14:34 UTC | newest]

Thread overview: 19+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2017-02-22 00:12 [PATCH 09/13] Fix the resource owner to be used Kyotaro Horiguchi <[email protected]>
2025-09-04 14:34 [PATCH v2 1/4] Add ternary reloption type Nikolay Shaplov <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox