Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aNn7R-0007LZ-4w for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Jan 2016 19:48:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aNn7Q-0004ti-M4 for pgsql-bugs@arkaria.postgresql.org; Mon, 25 Jan 2016 19:48:08 +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) (envelope-from ) id 1aNn6n-0004CQ-02 for pgsql-bugs@postgresql.org; Mon, 25 Jan 2016 19:47:29 +0000 Received: from mail-lb0-x22c.google.com ([2a00:1450:4010:c04::22c]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aNn6j-0000dT-Bc for pgsql-bugs@postgresql.org; Mon, 25 Jan 2016 19:47:27 +0000 Received: by mail-lb0-x22c.google.com with SMTP id x4so80962552lbm.0 for ; Mon, 25 Jan 2016 11:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joh-to.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=0o/uCrTzV9BSodcIepJ6KHWA8vBAnmlVUlB140EDXRc=; b=nfo2veGSLqBnxTJ5h1QBM+Lo0btNo/AfrinSvjIwKEIhOzkF561vJUUa288ACMcncv FI95R+TXnPy5injmznSV2VmO3EXl1b/zuIEQck1AaaxkDabQp5gQW1k0hj0toT/vhfGy zq/MQ3dDVK5GT3YqOXX0gkdfywJL85K3gxncEaBnfTjYNhoEo9Q6twrGYE1MrAN/8V+v Vu9qh94z93VE8GrN1wPzjH08Cg8g0orGIgvs+6fRsG7RffifbjxYJ9WHS0E1sdahWHt4 iMwGoXDo2F0jXzBbDTmmHQO1tmL/5G+Y8eQQj7jKEtQdPhLjGLWQfyl1KOZOdzb62b2/ rguA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=0o/uCrTzV9BSodcIepJ6KHWA8vBAnmlVUlB140EDXRc=; b=e+zuXvHZjT90p9wLOiR8LAFGpUVmF+7rPp6QitTeHUFdHWRd8Ob7XBrLKpmbmYaKAg RxHSkL+1R7gXHuapLru7lkloi1P6tnX/FoCzbR/p3O6L0Kc+imvn9cVf/vaQi5SFFRsg DoaSDtdTuD0yQ1aEdNJdMaMC4reMAe4nO0qEroNCpMQ8N9NUgz4YSqUIBTuQ8NmptwRh DUGamNUIeKYJmb8OaKKvnpG2JFbcj7R5d+k0vMlnx54WSQnEykNvLk+v9AF75JFhh4xr pPzI5PcvGYGU2FstLmQTsQBo2+5f7IhORNGnUAS4a0kyAfaC10ZUReVg8k06WeWdnT43 HHkw== X-Gm-Message-State: AG10YOQGVWB9avTkx78BrhoTH7fF9NtRwYYU4/rwKKMUbdPVFm38Z9EJqUL/uxUhDNjOiQ== X-Received: by 10.112.16.168 with SMTP id h8mr6892130lbd.90.1453751243140; Mon, 25 Jan 2016 11:47:23 -0800 (PST) Received: from [172.20.10.2] ([94.234.170.32]) by smtp.googlemail.com with ESMTPSA id u19sm2912429lfd.46.2016.01.25.11.47.18 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jan 2016 11:47:22 -0800 (PST) Subject: Re: BUG #13886: When INSERT ON CONFLICT DO UPDATE updates, it returns INSERT rather than UPDATE To: Peter Geoghegan References: <20160125074806.2555.44482@wrigleys.postgresql.org> <56A5F246.3070300@joh.to> Cc: rwestlun@gmail.com, pgsql-bugs From: Marko Tiikkaja Message-ID: <56A67BA7.7020201@joh.to> Date: Mon, 25 Jan 2016 20:46:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2016-01-25 8:35 PM, Peter Geoghegan wrote: > On Mon, Jan 25, 2016 at 2:00 AM, Marko Tiikkaja wrote: >> FWIW, I would've expected to be able to do RETURNING excluded.foo which >> would have been NULL in case of INSERT, and the value from the updated tuple >> otherwise. But that doesn't seem to work. > > The problem with that approach is that it makes both the target table > and the excluded pseudo table visible from within RETURNING. If we > were to do that, virtually every use of INSERT with both an ON > CONFLICT DO UPDATE clause and a RETURNING clause breaks. That's > because any unqualified column reference becomes ambiguous ("Did you > mean target.foo or excluded.foo?"). Surely there's a way to make this work so that EXCLUDED is a special tuple whose fields are normally not in scope, but can be accessed explicitly. But this discussion belongs to -HACKERS, as you said upthread. .m -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs