Don't use SMP in copy.

This commit is contained in:
totaj
2023-11-29 15:52:33 +08:00
parent 73622516e3
commit f0458d37f5
3 changed files with 22 additions and 2 deletions

View File

@ -2587,8 +2587,21 @@ static CopyState BeginCopy(bool is_from, Relation rel, Node* raw_query, const ch
Assert(query->commandType == CMD_SELECT);
Assert(query->utilityStmt == NULL);
/* plan the query */
plan = planner(query, 0, NULL);
bool old_smp_enabled = u_sess->opt_cxt.smp_enabled;
u_sess->opt_cxt.smp_enabled = false;
PG_TRY();
{
/* plan the query */
plan = planner(query, 0, NULL);
}
PG_CATCH();
{
u_sess->opt_cxt.smp_enabled = old_smp_enabled;
PG_RE_THROW();
}
PG_END_TRY();
u_sess->opt_cxt.smp_enabled = old_smp_enabled;
/*
* Use a snapshot with an updated command ID to ensure this query sees

View File

@ -148,4 +148,8 @@ select * from test3 order by 1;
2
(2 rows)
set query_dop=1004;
copy (select * from test3 order by 1 limit 1) to stdout header csv;
c
1
drop table test3;

View File

@ -93,4 +93,7 @@ select 0\; copy test3 from stdin\; copy test3 from stdin\; select 1; -- 1
2
\.
select * from test3 order by 1;
set query_dop=1004;
copy (select * from test3 order by 1 limit 1) to stdout header csv;
drop table test3;