Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ekKHu-0002LG-CH for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Feb 2018 01:49:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ekKHt-000715-8Y for pgsql-hackers@arkaria.postgresql.org; Sat, 10 Feb 2018 01:49:09 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ekKHs-00070v-Qe for pgsql-hackers@lists.postgresql.org; Sat, 10 Feb 2018 01:49:09 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ekKHp-0004BK-Qt for pgsql-hackers@postgresql.org; Sat, 10 Feb 2018 01:49:07 +0000 Received: by mail-wr0-x241.google.com with SMTP id u60so7239293wrb.8 for ; Fri, 09 Feb 2018 17:49:05 -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=CXDA/XFgwKT/2DyPOKGINTWINm0c3OGrn2R3EDL2LCk=; b=BNbnWYQQEMhtM6O9Slv+cKks6zbgu65TXCTPMPPPD0jPzpZ0kxLZshuTq9D5fEjLX8 dQr4vdaxRMWak3lDrYJrBoPeXL0ChsvITLiDjUfzxFGVvVuwGA/osG25PtkDqVXawwKI OnwP1nHnA+6Y2wQ+TcZRFpw81jQWkvh1Xwmk9m7ColDWayIIejvP/0WYeaO/3E/mPPJ8 /UEExvQydsGKS9XOmyw0HsjBVV86q+vQDHxdInf8yLGi4QbYTptCLMTVFKsNMtkmJEmP NamEBCkxrTnmsz3xVasarD7Rlr09TvW4u3vrGIs68rm92VxnmLEU6zmveIkFAEEdleXq Hvhg== 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=CXDA/XFgwKT/2DyPOKGINTWINm0c3OGrn2R3EDL2LCk=; b=lR1NGOVLlOyj02BevqSxemjlERXhNyfj9geH5n5PDH2d5hRjU7h8aXg9DkmGZsrBMd TOe4ufdj+mRgaesMSyKD/C50JD2Kjn81maCtoUi37Z7N7B0Xy3xjiKIG3lKiYNkoOgpg nWMSvrVBKCSh1go/mv6VE6UJGBLzob3/GrkMeT4g0Vj/EpidLw0TQLvrg8rPYsH4iXHz ITF2tkjXKuQRGPaKRncXRZurt7qod/MO3ICxfsqSxAyQ6JkX+HoKf7ULZZE3SU+b30ma kobGIKpwhpjmX76Mje/Q92rGf1iq1dEuLKCstjbIUpDkS/JGcIpy3zW3Ax4XjO+DroQZ qsqA== X-Gm-Message-State: APf1xPAgr95wGy5rmqMLNklQ9xCrmvs4EiinDLXBRCNiv7xCIeSQAMmX k6iwgf4xbbocHaicM5uwNivgvOk7EsSzeWwEcZlygHXIAmYloWkjcU7nEgagCU+JV0yAMyn6PzK 03ejiqYw3fK0E2GWRlTfAXzrg9eTsfab2b7MxejtVspxka0oTd4Z0DgFUXFKm+qQsIgR5fIct9w tUrCU7C+t4 X-Google-Smtp-Source: AH8x227LJnfQli2srUZiY8mZYdf9AGsMgUYXjgvlB58eiPzqEC+1x3cL4qG1T74eeIwoDL6Jbmp6/Q== X-Received: by 10.223.184.102 with SMTP id u35mr3844719wrf.143.1518227344015; Fri, 09 Feb 2018 17:49:04 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id w23sm1254917wra.80.2018.02.09.17.49.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 17:49:02 -0800 (PST) Subject: Re: [HACKERS] MERGE SQL Statement for PG11 To: Pavan Deolasee Cc: Peter Geoghegan , Robert Haas , Simon Riggs , Alvaro Herrera , Andrew Dunstan , Pavan Deolasee , Stephen Frost , PostgreSQL-development References: <50394f44-af78-b40f-313a-5b0f8a0450e4@2ndquadrant.com> From: Tomas Vondra Message-ID: <0bd07f01-8c0e-1205-df90-a9ae77dafa5b@2ndquadrant.com> Date: Sat, 10 Feb 2018 02:49:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: 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 Hi, On 02/07/2018 10:24 AM, Pavan Deolasee wrote: > > ... > > Here is v15 of the patch. > I've been looking at this version of the patch, mostly to educate myself before attempting to write the "status summary". One bit that I don't quite understand is GetXactWALBytes(). It pretty much just returns XactLastRecEnd and is used in ExecMerge like this: int64 startWAL = GetXactWALBytes(); bool qual = ExecQual(action->whenqual, econtext); /* * SQL Standard says that WHEN AND conditions must not * write to the database, so check we haven't written * any WAL during the test. Very sensible that is, since * we can end up evaluating some tests multiple times if * we have concurrent activity and complex WHEN clauses. * * XXX If we had some clear form of functional labelling * we could use that, if we trusted it. */ if (startWAL < GetXactWALBytes()) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot write to database ..."))); I think this actually fails to enforce the rule, because some writes may not produce WAL (think of unlogged tables). I also suspect it may be incorrect "in the opposite direction" because a query may not do any changes and yet it may produce WAL (e.g. due to wal_hint_bits=true). So we may need to think of a different way to enforce this ... regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services