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 1gLwpJ-0004MG-2j for pgsql-hackers@arkaria.postgresql.org; Sun, 11 Nov 2018 20:59:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gLwpH-0000OG-23 for pgsql-hackers@arkaria.postgresql.org; Sun, 11 Nov 2018 20:59:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gLwpG-0000Ng-Ii for pgsql-hackers@lists.postgresql.org; Sun, 11 Nov 2018 20:59:22 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gLwpD-0005oV-8S for pgsql-hackers@lists.postgresql.org; Sun, 11 Nov 2018 20:59:21 +0000 Received: by mail-wm1-x32a.google.com with SMTP id v70-v6so5904975wmd.1 for ; Sun, 11 Nov 2018 12:59:19 -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=NAdUq+SE68u49ABOnk0M6plTB8pVuVDvMxqvlWgHrUI=; b=EjprSES+wDEeJ/bckU3ZQELnDvzi/kPrSlG3TDWoxKa1SfQ3H1uXoGLvyVRePMyyve aAY7Q51zqIBRhF1azmclzpHMvPFVoAHx6bqBfr5DGlsttQ8syLNRrABnib5Ake3RPBit 9Wow45CJ2V5kYlkHBs8rGhu09VIeDpQHzmzaQitmiJj7o3XgDp3b8hJElJiALW9Q+skQ AKesIjtFK4iyYOvuhOHGmSH2ph6CdJTC9t0Th05dyjRxk80hG0Ruc9Hw+46lYQSH5Rci f7Mj6G3+SQs+Vz+crmTco2e+howU3Uzhx3TclNvhBichauLHqJg6WTseZIWCZYD45Mub dL9g== 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=NAdUq+SE68u49ABOnk0M6plTB8pVuVDvMxqvlWgHrUI=; b=WRJiD6ptD78k4Sx1HXuzMwI/8gsXpvk5i/AfgSsGL7veTutmSeTvf66ayDEIgP5087 OUiLcmEUkSiImdLsscrwmXY9mwzd2gw7y0WDHyGRkhIRvl6xH8QKVc67+mEw/WcfJC1r REFdJchWW2vFF2p0V+8paw6RW0um5SnxygzFTIIutIYWn5nLEpHmf5CsNHqzK990IoKY +joQv5YzaU9loghgPo/1tue1DuRJwYUaldewD0iBszbHROAS88DGZf2ESkDRLGbO1Brq uzeGvnBiptgyjuR0R9vemXpWp0iXKW+nWpYxh7zZxdFUDXstuqj9NtdsEhFbLGm9R/JR B4Cw== X-Gm-Message-State: AGRZ1gKkMS4KqhxztqK8J4gKmI1cjSMN5fdshcWEWghw3GdPCar2ASPy W7Hytf8OZWgUv1z2chVsPevjbw== X-Google-Smtp-Source: AJdET5fiXk9Ask7A7aHkTxOu6HZ+qBEzG3nttcAVw8O1cMAUBnlS02uHnYsufTBipkv8KDpz8HHMtQ== X-Received: by 2002:a1c:c604:: with SMTP id w4-v6mr6061782wmf.40.1541969956928; Sun, 11 Nov 2018 12:59:16 -0800 (PST) Received: from [10.137.2.19] (ip-86-49-251-50.net.upcbroadband.cz. [86.49.251.50]) by smtp.gmail.com with ESMTPSA id o15-v6sm11708487wrw.47.2018.11.11.12.59.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Nov 2018 12:59:16 -0800 (PST) Subject: Re: COPY FROM WHEN condition To: Adam Berlin , pgsql-hackers@lists.postgresql.org Cc: Surafel Temesgen References: <154177868369.24563.8425283889569429535.pgcf@coridan.postgresql.org> From: Tomas Vondra Message-ID: <7f9880a1-416e-649d-3a5a-e36bff538814@2ndquadrant.com> Date: Sun, 11 Nov 2018 21:59:13 +0100 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: <154177868369.24563.8425283889569429535.pgcf@coridan.postgresql.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/9/18 4:51 PM, Adam Berlin wrote: > As a newcomer to this patch, when I read this example: > > COPY table_name WHEN (some_condition) > > .. I expect COPY to only be run when the condition is true, and I do not expect the WHEN clause to filter rows. I'm curious what you think about: > Hmmm. Currently we have WHEN clause in three places: 1) triggers, where it specifies arbitrary expression on rows, determining whether the trigger should be invoked at all 2) event triggers, where it does about the same thing as for regular triggers, but only expressions "column IN (...)" are allowed 3) CASE WHEN ... THEN ... I'd say 3 is rather unrelated to this discussion, and 1+2 seem to support you objection to using WHEN for COPY, as it kinda specifies whether the command itself should be executed. > COPY table_name WHERE (some_condition) > > Users should already be familiar with the idea that WHERE performs a filter. > So, what about using FILTER here? We already use it for aggregates when filtering rows to process. That being said, I have no strong feelings either way. I'd be OK with both WHEN and WHERE. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services