Fix handling of volatile expressions in COPY FROM ... WHERE
authorTomas Vondra <[email protected]>
Tue, 22 Jan 2019 22:11:17 +0000 (23:11 +0100)
committerTomas Vondra <[email protected]>
Tue, 22 Jan 2019 22:11:17 +0000 (23:11 +0100)
The checking for calls to volatile functions in the COPY FROM ... WHERE
expression was treating all WHERE clauses as if containing such calls.
While that does not produce incorrect results, this disables batching
which may result in significant performance regression.

Discussion: https://www.postgresql.org/message-id/flat/CALAY4q_DdpWDuB5-Zyi-oTtO2uSk8pmy+dupiRe3AvAc++1imA@mail.gmail.com

src/backend/commands/copy.c

index c410e0a0dd6df1e047d409556c2ba95eb1c5c355..03745cca753f83656e3d6dfee9e8b15e86311857 100644 (file)
@@ -2612,8 +2612,7 @@ CopyFrom(CopyState cstate)
         */
        insertMethod = CIM_SINGLE;
    }
-   else if (cstate->whereClause != NULL ||
-            contain_volatile_functions(cstate->whereClause))
+   else if (contain_volatile_functions(cstate->whereClause))
    {
        /*
         * Can't support multi-inserts if there are any volatile funcation