COPY planning

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: COPY planning
Date: 2015-09-21 19:16:02
Message-ID: 20150921191602.GE88970@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I noticed that COPY calls planner() (this was introduced in 85188ab88).
I think it should be calling pg_plan_query() instead. The latter is a
very thin wrapper around the former which simply adds a couple of
logging entries, DTrace hooks for start/end, and a debugging cross-check
for plan node copying.

I came across this because I was considering adding some code to
pg_plan_query, so I would have needed to essentially duplicate it in the
COPY path, which seemed bad. (I have since abandoned the idea, but this
seems a reasonable thing to change nonetheless.)

diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index e98f0fe..94b2f8f 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -1414,7 +1414,7 @@ BeginCopy(bool is_from,
Assert(query->utilityStmt == NULL);

/* plan the query */
- plan = planner(query, 0, NULL);
+ plan = pg_plan_query(query, 0, NULL);

/*
* With row level security and a user using "COPY relation TO", we

--
Álvaro Herrera 33.5S 70.5W

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2015-09-21 19:34:46 Re: LW_SHARED_MASK macro
Previous Message Tom Lane 2015-09-21 19:09:11 Re: COMPARE_POINTER_FIELD been dead 13 years after living 2 weeks