diff options
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/heap/heapam.c | 12 | ||||
-rw-r--r-- | src/backend/access/transam/parallel.c | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 6db62410979..0b3332ecf5d 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -1131,13 +1131,7 @@ relation_open(Oid relationId, LOCKMODE lockmode) /* Make note that we've accessed a temporary relation */ if (RelationUsesLocalBuffers(r)) - { - if (IsParallelWorker()) - ereport(ERROR, - (errcode(ERRCODE_INVALID_TRANSACTION_STATE), - errmsg("cannot access temporary tables during a parallel operation"))); MyXactAccessedTempRel = true; - } pgstat_initstats(r); @@ -1183,13 +1177,7 @@ try_relation_open(Oid relationId, LOCKMODE lockmode) /* Make note that we've accessed a temporary relation */ if (RelationUsesLocalBuffers(r)) - { - if (IsParallelWorker()) - ereport(ERROR, - (errcode(ERRCODE_INVALID_TRANSACTION_STATE), - errmsg("cannot access temporary tables during a parallel operation"))); MyXactAccessedTempRel = true; - } pgstat_initstats(r); diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c index 74a483e0fd9..ab5ef2573cf 100644 --- a/src/backend/access/transam/parallel.c +++ b/src/backend/access/transam/parallel.c @@ -17,6 +17,7 @@ #include "access/xact.h" #include "access/xlog.h" #include "access/parallel.h" +#include "catalog/namespace.h" #include "commands/async.h" #include "libpq/libpq.h" #include "libpq/pqformat.h" @@ -67,6 +68,8 @@ typedef struct FixedParallelState Oid database_id; Oid authenticated_user_id; Oid current_user_id; + Oid temp_namespace_id; + Oid temp_toast_namespace_id; int sec_context; PGPROC *parallel_master_pgproc; pid_t parallel_master_pid; @@ -288,6 +291,8 @@ InitializeParallelDSM(ParallelContext *pcxt) fps->database_id = MyDatabaseId; fps->authenticated_user_id = GetAuthenticatedUserId(); GetUserIdAndSecContext(&fps->current_user_id, &fps->sec_context); + GetTempNamespaceState(&fps->temp_namespace_id, + &fps->temp_toast_namespace_id); fps->parallel_master_pgproc = MyProc; fps->parallel_master_pid = MyProcPid; fps->parallel_master_backend_id = MyBackendId; @@ -1019,6 +1024,13 @@ ParallelWorkerMain(Datum main_arg) /* Restore user ID and security context. */ SetUserIdAndSecContext(fps->current_user_id, fps->sec_context); + /* Restore temp-namespace state to ensure search path matches leader's. */ + SetTempNamespaceState(fps->temp_namespace_id, + fps->temp_toast_namespace_id); + + /* Set ParallelMasterBackendId so we know how to address temp relations. */ + ParallelMasterBackendId = fps->parallel_master_backend_id; + /* * We've initialized all of our state now; nothing should change * hereafter. |