Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u9Mam-000xXO-8M for pgsql-general@arkaria.postgresql.org; Mon, 28 Apr 2025 11:24:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1u9MZm-000Nwr-36 for pgsql-general@arkaria.postgresql.org; Mon, 28 Apr 2025 11:23:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1u9MZl-000Nwh-Iz for pgsql-general@lists.postgresql.org; Mon, 28 Apr 2025 11:23:06 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u9MZi-002Wsi-2P for pgsql-general@lists.postgresql.org; Mon, 28 Apr 2025 11:23:06 +0000 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-3018e2d042bso3073894a91.2 for ; Mon, 28 Apr 2025 04:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wikimedia.org; s=google; t=1745839381; x=1746444181; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ROJ76NIgCm6fXvJu5JhPX54sLS3yc5BhocKFFA06LKE=; b=CTaA90F7tnaktC6Ar1/7cl/ig//G/aHm3j9HTdixnAcLzTjU8AXDZlM+qMUisR5FNF qiqIeKnf2nsGOFwn2o3ayvNEudoGkNnDb1JL3DS/rAV/h3zHxzkBcrcvEvI9g/pduY6Y /aqMh9KJcWwsyfLxjn00xP0OBEE37bKxDsPNE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745839381; x=1746444181; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ROJ76NIgCm6fXvJu5JhPX54sLS3yc5BhocKFFA06LKE=; b=k/HQ2C3yUt/NHoWxBZD7PcIE4m5Ug2ZCv/VgEfn1NhTlAQkcBW7vWFUhCroktgdHvI Gmgzb5fkxqV8z125Oo8cOr7yBdbCky0+H7v++0UN4fsfvLAKQCuhzUJBukh/kzeUbZ7C 1ijIqGwrzmJMx5Q64JwKpv5xwZIXNs4Wm59Z3SgKu2sLFZhL1I91PrNw8zaMPu49K2Nq rxnd0VsUtu8Ao2HC75wyiKw7PKotWFgF8qiMI1XxH13d4JhitcoQEl5jCmpcJweHvfrF mnNjnJq9kJuBTiKCSL7BTpo17lIggo5JaVfzwrE/gmrdePPoOGkhYNOowWyMTv6K+I7T IWHw== X-Gm-Message-State: AOJu0YwudHQxyAjAgJ52/wgiXIt3OoT3jjQa/1vjROfK9y+CTr6pssZt vh35w4NTsocfqGlD9wMkbQnWPXtgzwsW0NkJGHY1gJ+simUrN+priZgVQavjZ8wVGOk+p74MevC +1Js= X-Gm-Gg: ASbGncsa9FDy4EVnAxrqo9/fsiCfq3dxjME5IGhlVjeZqwsgDU+xZHkpeCrRAAwD+TE hwsVwiUQo+OTtFZjhA43M5gbwjslLnC/928hUi/igRhZOgwUVl32yVbMP9u2e6ff0H27ptaSWiZ BxMVbYNVxqOqTz7b0z0nF8+u9CZts661FH9H2H4xEVDfNrAvKBJOXLgfDEQtse5nU6o11Z7WYRr BLReAIfJ12pSy7zqvrWaL6dFlrp2vxhUETX9T3036S9S7n+kSxvfplrDh2NHQsM/MRVuhiYR3om DZ0PTg31HAKe3YfjUXqsGWBPBEVizL83lMswaPqtX8djBL/b9eH09W1K5gCEYbZawYcLM1zRJD6 buqykxf0V+KNIbA== X-Google-Smtp-Source: AGHT+IHzmGvO4/+1GoXcWa9WVfeJgMQtGB/iuOG/Y0H5aFFjszjoia9Jkw7PEXnv8G0WPjU07s5rbQ== X-Received: by 2002:a17:90b:2dd1:b0:2ee:d371:3227 with SMTP id 98e67ed59e1d1-309f8db3972mr18827053a91.17.1745839381275; Mon, 28 Apr 2025 04:23:01 -0700 (PDT) Received: from [10.1.1.45] (124-168-128-17.dyn.iinet.net.au. [124.168.128.17]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-309d3472785sm8113965a91.0.2025.04.28.04.22.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Apr 2025 04:23:00 -0700 (PDT) Message-ID: <80f95342-cc09-4236-a2d7-68538fbfc41b@wikimedia.org> Date: Mon, 28 Apr 2025 21:22:56 +1000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Upsert error "column reference is ambiguous" Content-Language: en-US To: Tom Lane Cc: pgsql-general@lists.postgresql.org References: <697017.1745837694@sss.pgh.pa.us> From: Tim Starling In-Reply-To: <697017.1745837694@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 28/4/25 20:54, Tom Lane wrote: > Even if I were on board with arbitrarily adopting one of the two > possible interpretations, it's far from obvious to me that most people > would agree that "v" should mean the value from the existing row, > rather than the new value. Better to make them say which they want. OK sure, no way to tell, but if every other DBMS does it the same way then that might be a hint. Also, I'm just saying, the upsert feature is fully useless to me with this name resolution policy. In the single-row case, there's no need for EXCLUDED at all, because the client knows everything about the excluded row. Recall my example: INSERT INTO t VALUES (1,1) ON CONFLICT (k) DO UPDATE SET v=v+1; If I meant SET v=EXCLUDED.v+1 I would have just written v=2. The default policy (in other DBMSes) follows by analogy from the single-row case. -- Tim Starling