Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glOt9-0004Oi-KU for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jan 2019 02:00:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1glOt7-0008Va-CJ for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Jan 2019 02:00:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glOt7-0008VR-4d for pgsql-hackers@lists.postgresql.org; Mon, 21 Jan 2019 02:00:33 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1glOsz-000730-7T for pgsql-hackers@lists.postgresql.org; Mon, 21 Jan 2019 02:00:32 +0000 Received: by mail-wm1-x342.google.com with SMTP id b11so9305491wmj.1 for ; Sun, 20 Jan 2019 18:00:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=taw7bJ6/XX8Z67Ky8Au/K8qIpVi62pM+wtEbIaFCMog=; b=E6MW4jalS87Mj/MuU+aquMaeSqjmoEkjdmLigu4J8TKMHVGwwoPENwsJkZ+DanhYJ/ qCJgBjw0os7FOfIIXFgaHMOXRZ7G+kWfOUGDFnIoPRTtpxf0JFu9rtAGYu4v0tr7cWl0 NbSXZLNuOEgXnoYOzru/XaXahIx6dMhayRIouXV4EZx184Yd4peSTfdTK7e6/C22Qzes fm4YTz3drrdWDI5kvjheQ3Ckxw/RuMVBy82fzqG4PNqc0zg1Adyww7yXGD9sBaEdZgbs 7LvI30sAapla1Q35sM36VyIxnU/tflHKFPtRAFe9btSOXN1Ozic8ODVkDHdt1OTfF3N9 YnYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=taw7bJ6/XX8Z67Ky8Au/K8qIpVi62pM+wtEbIaFCMog=; b=TOf3IoUoJ+v2N85nhrvlTeRVgqyD10WzaIhLtc2x/TeQcsIzbpuDOKp2QZp+eBi3cP E5DAQlD8rESnp/jhbuEHkHGnYo0+yZzugffhVfZdwurHAYGPJWG4v85ZU2/mpBQ9pK0w ze7n6zCTwHYUj4mt77vkw/xMc4vZ8+jS6FHlFMAHh1K6OW1ojpnwjh9r9npa392oxhzI 1Slt6Q3UawPRZ3x0NtEjU6s6DxFZcAcLdnh9GF7iMIQSdlknA4wa4kCRjmhlYeyslmPg S1Xxmw67OjhGDcMHBlsUBIPbQ0d6l8lVoh9CY5Seko3vYyRsWlw/8W/bzTxI8N6533+p rhiQ== X-Gm-Message-State: AJcUukcODNdu4mBNzb4gIbGI48+0q4PEMJmlG1NQk3XaFofI49zS9Zj7 vRPnbp/oqSj/zuurzCPaeb/U7IwTraqbbE3OOTvn0IWaMjeKb674lvcHf1l3ATHN4AnD+OYMp1A t6gYvWYG3dVdzuQBNFETxqwFGXVw5OcWeHJgOrvPKeF7/pU47CY6ZcYuUcxc9pK8jUBYP6BX5lA mn5vp7uYVJUHZGoPFsVmw= X-Google-Smtp-Source: ALg8bN4VdrOMc9klvvby+OxFbgktDfKshPrcIwwVln+XlaKJr18t24Mo++/9PsW6eYMyUCFrFlPHVQ== X-Received: by 2002:a1c:38c4:: with SMTP id f187mr22369980wma.90.1548036023231; Sun, 20 Jan 2019 18:00:23 -0800 (PST) Received: from [10.137.0.20] (ip-86-49-251-50.net.upcbroadband.cz. [86.49.251.50]) by smtp.gmail.com with ESMTPSA id x20sm67442456wme.6.2019.01.20.18.00.22 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sun, 20 Jan 2019 18:00:22 -0800 (PST) Subject: Re: COPY FROM WHEN condition To: Andres Freund Cc: Surafel Temesgen , alvherre@2ndquadrant.com, Adam Berlin , pgsql-hackers@lists.postgresql.org References: <194e2225-b186-9325-0cd1-9a5b09d28251@2ndquadrant.com> <20181204094418.wpr6mxrtsuxb5mlq@alvherre.pgsql> <3b2b1aac-5861-acd8-fda3-054c4e4da888@2ndquadrant.com> <20190121012405.633row4iw7nfxz7h@alap3.anarazel.de> From: Tomas Vondra Message-ID: <6e80b7c1-58cd-4212-41d3-7c519aed0500@2ndquadrant.com> Date: Sun, 20 Jan 2019 21:00:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20190121012405.633row4iw7nfxz7h@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/20/19 8:24 PM, Andres Freund wrote: > Hi, > > On 2019-01-20 00:24:05 +0100, Tomas Vondra wrote: >> On 1/14/19 10:25 PM, Tomas Vondra wrote: >>> On 12/13/18 8:09 AM, Surafel Temesgen wrote: >>>> >>>> >>>> On Wed, Dec 12, 2018 at 9:28 PM Tomas Vondra >>>> > wrote: >>>> >>>> >>>> Can you also update the docs to mention that the functions called from >>>> the WHERE clause does not see effects of the COPY itself? >>>> >>>> >>>> /Of course, i  also add same comment to insertion method selection >>>> / >>> >>> FWIW I've marked this as RFC and plan to get it committed this week. >>> >> >> Pushed, thanks for the patch. > > While rebasing the pluggable storage patch ontop of this I noticed that > the qual appears to be evaluated in query context. Isn't that a bad > idea? ISMT it should have been evaluated a few lines above, before the: > > /* Triggers and stuff need to be invoked in query context. */ > MemoryContextSwitchTo(oldcontext); > > Yes, that'd require moving the ExecStoreHeapTuple(), but that seems ok? > Yes, I agree. It's a bit too late for me to hack and push stuff, but I'll fix that tomorrow. cheers -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services