COPY planning - Mailing list pgsql-hackers

From Alvaro Herrera
Subject COPY planning
Date
Msg-id 20150921191602.GE88970@alvherre.pgsql
Whole thread Raw
Responses Re: COPY planning  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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
relationTO", we
 

-- 
Álvaro Herrera                            33.5S 70.5W



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: COMPARE_POINTER_FIELD been dead 13 years after living 2 weeks
Next
From: Alexander Korotkov
Date:
Subject: Re: LW_SHARED_MASK macro