Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eAK1z-0004sv-CR for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2017 18:15:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eAK1x-0001kW-SB for pgsql-hackers@arkaria.postgresql.org; Thu, 02 Nov 2017 18:15:53 +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_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eAK0O-0007Lf-Qb for pgsql-hackers@postgresql.org; Thu, 02 Nov 2017 18:14:16 +0000 Received: from mail-pg0-x22d.google.com ([2607:f8b0:400e:c05::22d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1eAK0L-0006z2-34 for pgsql-hackers@postgresql.org; Thu, 02 Nov 2017 18:14:16 +0000 Received: by mail-pg0-x22d.google.com with SMTP id r25so309610pgn.4 for ; Thu, 02 Nov 2017 11:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowt-ie.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=f08lIlD6wokBROD56fJ1CYjY+TJ8i4pp6N/w9grZldA=; b=ZVcHrXkLk/e+9QVNE/WROz2r+Ymy6LRI4dd3pqM3WLIQeUuNgpA9vq6G8kX8DOI58y U6/9MkdEtNJ2kbzNml4v42Y+gnjGEwPX4Y0u4OoKcVfPcaeqQ167xomYMHCM1/lhCL8x Pdj6nYKjJoJWnk0BPs7ezRSpNUe+j2Ci7bh9Hlhniwu4R2J6mGowdcsCHmO4Ose0mdX8 xPxxt51+mEgVd/yH9z7nWIbgFmvzR/QL/y/ZnESnWK3Jf1B3y/5IhTQ5uT+IyFGQZf6X LSyiN6Jaj4RgwMV3uTloRmnUNsJlqjuH5W6Ym/GwcEbV0/ZSGw8m6qhVdpBrWTOxJrQF M58A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=f08lIlD6wokBROD56fJ1CYjY+TJ8i4pp6N/w9grZldA=; b=UCzaKjFu8bqshpm+RvfX2XPnOk33pYjDjarfeY05iYQj8XBT4No1JnX0SAqW/bBzec +ggQkHl6FuG6pvwwaTr9G+NUZlLZx9LJJaeThCPeBKL5wcHl0EhZkyUVJ6CJJ0ytDPOJ XFdet8yNbxtgzFHLZL9ZKp9TXgVbK74TKahOdsWAGarXwRg1M5iYwTC4RonQI/pWxj4R zbooVWxl8cmc0oDH2SY+b5TdpI6xwHwSJRbcvFtcpTmWZLQxvF0Bpo4rgEPukbeKg0Mg Q0qVsIIH9Qe07ULKOcF16M8RuJkec0olWP7Kg/8f+dcKC5ANgna8EiLxQWaZj+4VajyI r6UQ== X-Gm-Message-State: AMCzsaVeE36ryYUTWWTnIlcOcsvNSDBpnEfD/aPqzheLDxSJRydWBu98 toOuH5mO1uM51ImMEGM+7t+isw== X-Google-Smtp-Source: ABhQp+TIVob3qYMz0Ytn+xWrVmHIo3i5wcC1LCxkJMPBpchcJUvGpIucj0o19tOTVDnRLTNxIXLa3w== X-Received: by 10.84.233.8 with SMTP id j8mr4200233plk.311.1509646450318; Thu, 02 Nov 2017 11:14:10 -0700 (PDT) Received: from marmot ([162.217.72.7]) by smtp.gmail.com with ESMTPSA id c73sm9169783pfd.139.2017.11.02.11.14.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 11:14:09 -0700 (PDT) Date: Thu, 2 Nov 2017 11:14:01 -0700 From: Peter Geoghegan To: Robert Haas Cc: Simon Riggs , Stephen Frost , Michael Paquier , PostgreSQL-development Subject: Re: MERGE SQL Statement for PG11 Message-ID: <20171102181401.GB23098@marmot> References: <20171030185511.GJ4628@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Robert Haas wrote: >And if, in the meantime, MERGE can only handle the cases where there >is a unique index, then it can only handle the cases INSERT .. ON >CONFLICT UPDATE can cover, which makes it, as far as I can see, >syntactic sugar over what we already have. Maybe it's not entirely - >you might be planning to make some minor functional enhancements - but >it's not clear what those are, and I feel like whatever it is could be >done with less work and more elegance by just extending the INSERT .. >ON CONFLICT UPDATE syntax. +1 Marko Tiikkaja's INSERT ... ON CONFLICT SELECT patch, which is in the current CF [1], moves things in this direction. I myself have occasionally wondered if it was worth adding an alternative DO DELETE conflict_action. This could appear alongside DO UPDATE, and be applied using MERGE-style conditions. All of these things seem like small adjuncts to ON CONFLICT because they're all just an alternative way of modifying or projecting the tuple that is locked by ON CONFLICT. Everything new would have to happen after the novel ON CONFLICT handling has already completed. The only reason that I haven't pursued this is because it doesn't seem that compelling. I mention it now because It's worth acknowledging that ON CONFLICT could be pushed a bit further in this direction. Of course, this still falls far short of making ON CONFLICT entirely like MERGE. [1] https://commitfest.postgresql.org/15/1241/ -- Peter Geoghegan -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers