mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 16:02:15 +03:00
Allow DML commands that create tables to use parallel query.
Haribabu Kommi, reviewed by Dilip Kumar and Rafia Sabih. Various cosmetic changes by me to explain why this appears to be safe but allowing inserts in parallel mode in general wouldn't be. Also, I removed the REFRESH MATERIALIZED VIEW case from Haribabu's patch, since I'm not convinced that case is OK, and hacked on the documentation somewhat. Discussion: http://postgr.es/m/CAJrrPGdo5bak6qnPWe8Kpi8g_jfQEs-G4SYmG9y+OFaw2-dPvA@mail.gmail.com
This commit is contained in:
@ -2598,15 +2598,17 @@ heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid,
|
||||
CommandId cid, int options)
|
||||
{
|
||||
/*
|
||||
* For now, parallel operations are required to be strictly read-only.
|
||||
* Unlike heap_update() and heap_delete(), an insert should never create a
|
||||
* combo CID, so it might be possible to relax this restriction, but not
|
||||
* without more thought and testing.
|
||||
* Parallel operations are required to be strictly read-only in a parallel
|
||||
* worker. Parallel inserts are not safe even in the leader in the
|
||||
* general case, because group locking means that heavyweight locks for
|
||||
* relation extension or GIN page locks will not conflict between members
|
||||
* of a lock group, but we don't prohibit that case here because there are
|
||||
* useful special cases that we can safely allow, such as CREATE TABLE AS.
|
||||
*/
|
||||
if (IsInParallelMode())
|
||||
if (IsParallelWorker())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TRANSACTION_STATE),
|
||||
errmsg("cannot insert tuples during a parallel operation")));
|
||||
errmsg("cannot insert tuples in a parallel worker")));
|
||||
|
||||
if (relation->rd_rel->relhasoids)
|
||||
{
|
||||
|
Reference in New Issue
Block a user